-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Map associated rows to properties Hibernate?
PostPosted: Tue Mar 15, 2005 1:54 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 11:51 am
Posts: 31
Hibernate version: 3.0

Name and version of the database you are using: SQL Server

Hello,
I know it sounds odd, but is it possible? This is a silly example, but for easier communication, let's say I had the following table structures:

Address
------------
ADDRESS_ID


Address_Info
-------------------
ADRESS_INFO_ID
FOREIGN_TABLE_NAME
FOREIGN_ID
STREET
CITY
STATE


.... and I wanted my Java bean as follows .....

Address.java
---------------------
Address_id
Street
City
State



Can this type of scenario be mapped in Hibernate? If so, could you please point out some key words to look for in the documentation?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 3:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
In hibernate 3 you can do stuff like:

Code:
<class name="Person">
       <id name="name"/>
       <one-to-one name="address" cascade="all" constrained="false">
           <formula>name</formula>
           <formula>'HOME'</formula>
       </one-to-one>
       <one-to-one name="mailingAddress" constrained="false">
           <formula>name</formula>
           <formula>'MAILING'</formula>
       </one-to-one>
   </class>
    <class name="Address" batch-size="2"
           check="addressType in ('MAILING', 'HOME', 'BUSINESS')">
       <composite-id>
           <key-many-to-one name="person"
                   column="personName"/>
           <key-property name="type"
                   column="addressType"/>
       </composite-id>
       <property name="street"/>
       <property name="state"/>
       <property name="zip"/>
   </class>


that should solve your issues i think.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 7:31 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 11:51 am
Posts: 31
Awesome. I think you got me going in the right direction. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.