-->
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: Glitch with CHAR based collection mappings
PostPosted: Mon Feb 28, 2005 10:21 pm 
Newbie

Joined: Wed Feb 16, 2005 12:44 am
Posts: 5
In a legacy database that I am accessing via hibernate I have a table [Claim_Detail] indexed by char(19) [Claim_Number].

I also have a table [Diary] that references [Claim_Detail] using char(22) [Ref_No]. There is no foreign key constraint defined. A foreign key would probably fail as the fields are different lengths, and I think [Ref_No] is used for other purposes.

In the ClaimDetail.hbm.xml mapping I set up the following collection for the Diary:

<set name="diarySet">
<key column="Ref_No" />
<one-to-many class="Diary" />
</set>

This collection would then never be populated. With logging set to DEBUG, I would see the correct query being run, and the correct number of results being hydrated. I even managed to get in with the debugger and see a Set being populated with all the object. But the Set given to the ClaimDetail object would be empty.

I eventually worked out that Hibernate appears to double check the results of the query before populating the Set. The check was failing because there was a different amount of whitespace.

I have now solved this problem by setting up a UserType that trims the char data, and all works well.

I don't know if this is a bug, or desired behaviour. But the debug output was misleading and made it difficult to diagnose why I wasn't getting any results. Maybe something as simple as logging when objects are discarded from a collection because they don't match would have made it easier.

Hibernate version:
2.1.8

Name and version of the database you are using:
MS SQLServer 2000


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.