-->
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: Simple Bidirectional OneToOne with JoinColumn not working
PostPosted: Fri Apr 16, 2010 11:36 am 
Regular
Regular

Joined: Thu Dec 10, 2009 10:53 am
Posts: 50
Hibernate Version
3.5.0.Final (with patch from http://opensource.atlassian.com/projects/hibernate/browse/HHH-3824)

I've been trying to map a bidirectional @OneToOne association using a @JoinColumn on a non-primary key, without much luck so far. It seems to me that the functionality is missing right now, as somebody supplied a patch to implement the functionality. Even with the patch I couldn't get it to work though. The association from HI to H is not correctly loaded from the DB and it's always null.

There are to entities H and HI associated with a bidirectional @OneToOne on the field objId and objIdHTarget respectively.
Here are the annotated POJOS:

Code:
public class H {
   private String id;
   private HI hiFormula;
    private String objId;
   private String value;

   public String getObjId() {
      return objId;
   }

   public void setObjId(String objId) {
      this.objId = objId;
   }

   @OneToOne(fetch=FetchType.LAZY)
   @JoinColumn(name = "objId", referencedColumnName = "objIdHTarget", nullable = false, insertable = false, updatable = false, unique = false)
   @ForeignKey(name = "none")
   public HI getHiFormula() {
      return this.hiFormula;
   }

   public void setHiFormula(HI hiFormula) {
      this.hiFormula = hiFormula;
   }
[..]
}


Code:
public class HI Serializable {
   private String id;
   private String objIdHTarget;
   private Date valid_from;
   private Date valid_until;
   private String author_from;
   private String author_until;
   private String branch_ID;
   private H h;

   @OneToOne(mappedBy="hiFormula")
   public H getH() {
      return this.h;
   }

   public void setH(H h) {
      this.h = h;
   }
[..]
}


Here's the log file:
[url]
http://paste.ideaslabs.com/show/oV5o0Fn2qH
[/url]

In the test I am simply creating a H, HI object with the matching fields and trying to load H in a different critieria and look at the getters for the association.


Top
 Profile  
 
 Post subject: Re: Simple Bidirectional OneToOne with JoinColumn not working
PostPosted: Mon Apr 19, 2010 8:05 am 
Regular
Regular

Joined: Thu Dec 10, 2009 10:53 am
Posts: 50
Nobody has an idea how to solve this?


Top
 Profile  
 
 Post subject: Re: Simple Bidirectional OneToOne with JoinColumn not working
PostPosted: Thu Apr 22, 2010 3:37 am 
Regular
Regular

Joined: Thu Dec 10, 2009 10:53 am
Posts: 50
BUMP


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.