2 Replies Latest reply on Dec 30, 2005 7:33 PM by Emmanuel Bernard

    Question about OneToOne relationships where other table's PK

    David Budworth Newbie

      I have two tables
      User (pkcol user_id(Long))
      UserDetail (pkcol user_id(Long), also foreign key to User)

      I read in the Hibernate Annotation Reference section (OneToOne)
      section a piece saying that the slave table should have the id itself mapped as the raw value (ie: mapped as Long, rather than User object).

      It states that the application logic must manually set the Id on the slave for now. That it would be implemented in the future to automatically set it.

      I was wondering if the documentation is up to date. I've been trying to see if I can do this style of mapping without adding an unused UserDetailId column and sequence (I'm using oracle) for all my tables that are 1-1 mapped like this.

      Ultimately, Id prefer to have something like:

      (semi-pseudo code here)

      class User{
       Long userId;
       UserDetail detail;
      class UserDetail{
       User user;

      Obviously simplified, but you get the jist (I hope).

      Will this be possible in the (near) future?

      In the mean time, I'll add extra id cols to my tables to get it working code wise (totally new development, doesnt hurt to make the tables a bit bigger)