-->
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: selecting, deleting, updating rows by NULL value id DB2
PostPosted: Thu Feb 17, 2005 7:05 am 
Newbie

Joined: Wed Dec 22, 2004 5:56 am
Posts: 9
Hi,

I have mapping (using Hibernate 2.1.8) of the child table as a set, with key and composite-element.

e.g.
[quote]<set ... sort="natural" ... cascade="all">
<key>
<column name="ID"/>
</key>
<composite-element class="Element">
<property name="nbr1" column="NBR1"/>
<property name="nbr2" column="NBR2"/>
</composite-element>
</set>[/quote]

But the property nbr2 can be null. And when I try to delete this elements from the set they are not removed from the DB2 database because the:

delete from ..... where .... NBR2=?

and seting the last parameter to NULL using preparedStatement.setNull(3, java.sql.Types.INTEGER) is not working! This is DB2 feature or it is common?

The only way out of this problem is to use map instead of set. There can i specify composite-index (all properties are not null) and composite-element, where can be null properties.

[quote]<map ... sort="natural" ... cascade="all">
<key>
<column name="ID"/>
</key>
<index column="NBR1"/>
<composite-element class="Element">
<property name="nbr2" column="NBR2"/>
</composite-element>
</map>[/quote]

BUT, i like the set behaviour, where I have all properties in 1 class. So is there any way how to add the index into the mapping of Element class?

Thanks,

Jirka


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 17, 2005 9:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You have to use "xxx is null" in your query


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 17, 2005 10:01 am 
Newbie

Joined: Wed Dec 22, 2004 5:56 am
Posts: 9
But it is Hibernate generated query. I found in documentation, that set can be used to map only composite-elements with not null all properties :-(

I realizaed the map mapping, but have another problem. When the composite-element has all columns NULL, Hibernate puts as value into map null instead of instance of the composite-element with all columns set to null??


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.