0 Replies Latest reply on Sep 6, 2006 12:24 AM by dennis zane

    One-To-One?how to make two tables share their primary key?

    dennis zane Newbie

      you see,in Hibernate,we can set a pojo to have an one-to-one relationship with the other entity by share their primary key,for example:


       <class name="TUser"
       table="user"
       ......
       <one-to-one name="passport"
       class="TPassport"
       cascade="all"
       outer-join="all"
       />
       </class>
      

      It is related with TPassport like:
       <class name="TPassport"
       table="user"
       >
       <id name="id" column="id">
       <generator class="foreign">
       <param name="property>user</param>
       </generator>
       </id>
       <one-to-one name="user"
       class="TUser"
       contrained="true" />
      

      the TPassport's primary key is genearted by TUser's,how to do that in ejb3?I tried many times,but failed.who can give me an example?thanks!