-->
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.  [ 1 post ] 
Author Message
 Post subject: How 1:1 Mapping into a Single Class
PostPosted: Tue Mar 14, 2006 4:01 pm 
Newbie

Joined: Tue Mar 14, 2006 11:52 am
Posts: 2
Hy,
got the following situation:

Two Database-Tables:

1. loc_entry_history:
- "ehid": primary key, auto_increment, unique
- "time": Timestamp
- "views": int

2. loc_entry_history_info:
- "ehid": foreign key on "loc_entry_history.ehid", primary key, unique
- "title": String
- "plz": String

As you can see, this results in a 1:1 mapping between loc_entry_history and loc_entry_history_info. I managed to get the Data into to classes ("History" and "Info") by the following config:
Code:
   <class name="de.dbruhn.framework.test.beans.History" table="loc_entry_history">
      <id name="id" column="ehid">
         <generator class="native" />
      </id>
      <property name="time" column="ehtime" type="timestamp" />
      <property name="ip" column="ehip" />
      <property name="views" column="ehviews" />
      
   </class>
   
   <class name="de.dbruhn.framework.test.beans.Info" table="loc_entry_info">
      <id name="id" column="ehid">
           <generator class="foreign">
               <param name="property">history</param>
           </generator>
       </id>
       <one-to-one name="history" constrained="true"/>
      
      <property name="title" column="eititle" />
      <property name="plz" column="eiplz" />
   </class>


but this is not what I want:
I want the Data to be stored in a single Class, so one Class with the Name "history" where also the "title" and "plz" are stored.

How can I do this? I tried changing the "class name="[...].Info" into "class name="[...].History" but then the property "history" is missing. But I cant add the property history to the class, it would be a self-reference.

Thanks for any help
TO


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

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.