-->
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.  [ 2 posts ] 
Author Message
 Post subject: Identifier in one-to-one mapping
PostPosted: Thu May 12, 2005 10:06 am 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I have a one to one mapping between Table A and Table B.
Table A's ID is generated using sequence class. I am not sure
how to set the identifier for the Table B whose ID would
be same as TableA ID.

When i execute session.save, I pass a single object which
contain both TableA and Table B information.

Any suggestion or thougts are highly appreciated.


Hibernate version:
3.0
Mapping documents:
<id name="id" column="col1">
<generator class="sequence">
<param name="sequence">seq</param>
</generator>
</id>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Re: Identifier in one-to-one mapping
PostPosted: Thu May 12, 2005 5:25 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
mahikty wrote:
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I have a one to one mapping between Table A and Table B.
Table A's ID is generated using sequence class. I am not sure
how to set the identifier for the Table B whose ID would
be same as TableA ID.

When i execute session.save, I pass a single object which
contain both TableA and Table B information.

Any suggestion or thougts are highly appreciated.

Code:
<hibernate-mapping package="gov.cdc.pems.www.cls.vo">

  <class name="A" table="TABLE_A">
    <id column="A_ID" name="id" type="java.lang.Long">
      <generator class="sequence(or whatever)"/>
    </id>
    .... other properties...
    <one-to-one name="b" class="B"/>
  </class>

  <class name="B" table="TABLE_B">
    <id column="B_ID" name="id" type="java.lang.Long">
      <generator class="foreign">
        <param name="property">a</param>
      </generator>
    </id>
    .... other properties...
    <one-to-one name="a" class="A" constrained="true"/>
  </class>
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.