-->
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.  [ 5 posts ] 
Author Message
 Post subject: Composite Id with nullable column problem
PostPosted: Wed Mar 21, 2007 9:51 am 
Newbie

Joined: Wed Mar 21, 2007 9:35 am
Posts: 1
Hello. I use Hibernate 3.2.1ga and found a problem while mapping entity for legacy database. Entity has a composite primary key with 6 columns:
- project name
- project version
- activity name
-resource name
which are not-null and
- start date
- finish date
any of which/or both are nullable.

When Hibernate fetches from database entities which have one-to-many relation to this one, the target collection is empty but as I can see SQL performed by Hibernate gives me in sqlplus 1 record whith "start date" (for example) = null. If I change both columns values in database to be not null, Hibernate gives me a collection of 1 element. It seems that Hibernate does not create a Java object and event its Id object if any of primary key columns is null.

Does Hibernate provide an ability to work with tables which have composite IDs with nullable column? How to resolve the problem?
Thanks in advance


Top
 Profile  
 
 Post subject: Re: Composite Id with nullable column problem
PostPosted: Sun Mar 25, 2007 9:22 am 
Newbie

Joined: Sun Mar 25, 2007 9:16 am
Posts: 2
Hi,

I'm having the same problem. All records are fetched from the database, but only those with all PK columns not null are loaded into the OneToMany list.
EntityManager.find() with some PK columns being null works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 4:33 am 
Beginner
Beginner

Joined: Fri Jan 27, 2006 4:20 am
Posts: 22
Same here too... but in my situation, that nullable column of my composite key is there to make the entire row unique, so the option of excluding it is not really feasible.. someone, anyone help us..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 8:48 am 
Newbie

Joined: Thu Mar 22, 2007 8:45 am
Posts: 8
I don't think Hibernate will work with PK or in your case Composite keys having null value. I had this issue before and I was wondering why I was not getting result on some of the rows. Then I was told that it was because I had null values in the PK.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 9:56 pm 
Beginner
Beginner

Joined: Fri Jan 27, 2006 4:20 am
Posts: 22
So.. any proposed solutions? (no no no... not pure jdbc...)


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