-->
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: optional @ManyToOne
PostPosted: Tue Jan 16, 2007 8:10 am 
Newbie

Joined: Fri Apr 22, 2005 3:39 pm
Posts: 18
Greetings! Could someone help me with this, please?

I have a very simple unidirectional many-to-one (an Member knows its Freelancetype). The type information should be optional e.g. when loading Member, Freelancetype should be either null (no PK-FK match in DB), or fully loaded. Instead when PK-FK match fails, I get non-null member. getFreelancetype(), where Freelancetype returned has null fields (including freelancetypeid). Looks like Hibernate decides to instantiate a new Freelancetype for a Member if it can't load one from DB.
How to avoid it?

Hibernate version:
3.2.0.cr2
Mapping documents:

Code:
@Entity
public class Member
{
   //...
   @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
   @JoinColumn(name = "freelancetypeid", unique = false, nullable = true, insertable = true, updatable = true)
   public Freelancetype getFreelancetype() {
      return this.freelancetype;
   }
   //...
}
@Etity
public class Freelancetype implements java.io.Serializable {
   private String freelancetypeid;
   private String freelancetypedesc;
//...
   @Id
   @Column(name = "freelancetypeid", unique = true, nullable = false, insertable = true, updatable = true, length = 2)
   public String getFreelancetypeid() {
      return this.freelancetypeid;
   }

}


Name and version of the database you are using:
PostgreSQL 8.1


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.