-->
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.  [ 4 posts ] 
Author Message
 Post subject: Manage query with null value
PostPosted: Mon Feb 14, 2005 10:17 am 
Newbie

Joined: Mon Feb 14, 2005 10:11 am
Posts: 10
Location: Italy
Hi, I've a problem with a query in hibernate.

I want to select all object where a particular field is null.
If I try to make this query "from Node as n where n.parent is null" it return an empty list of object type Node.

The database table that I interrogate has this structure and the following value

NODE_ID NAME HIERARCHY_ID PARENT_NODE_ID
103 Bologna 102 104
104 Emilia Romagna 102 <null>

If I make the sql query "select * from CLASSIFICATION_NODE where PARENT_NODE_ID is null" it work correctly and return the second row.

So what or where is the problem in the hibernate query ?

Thank you.

_________________
Ing. Marco Rinaldi - Italy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 10:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
check the generated SQL


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 10:48 am 
Newbie

Joined: Mon Feb 14, 2005 10:11 am
Posts: 10
Location: Italy
The genereted sql:

Hibernate: select node0_.NODE_ID as NODE_ID, node0_.NAME as NAME, node0_.HIERARCHY_ID as HIERARCH3_ from HT_CLASSIFICATION_NODE node0_ where (node0_.NODE_ID is null )

..... I didn't find errors or mistakes...

The mapping file of Node class is the following:
<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping >
<class name="it.satanet.adbpo.classification.Node" table="HT_CLASSIFICATION_NODE">

<id name="id" column="NODE_ID" type="long">
<generator class="native" />
</id>


<property name="name" column="NAME" type="string" length="50" not-null="true"/>

<many-to-one name="hierarchy"
column="HIERARCHY_ID"
class="it.satanet.adbpo.classification.Hierarchy"
not-null="true"
/>

<one-to-one name="parent" class="it.satanet.adbpo.classification.Node"/>

<set name="childs"
cascade="save-update"
lazy="true">
<key column="PARENT_NODE_ID"/>
<one-to-many class="it.satanet.adbpo.classification.Node"/>
</set>

</class>
</hibernate-mapping>

Could you help me ?

_________________
Ing. Marco Rinaldi - Italy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 12:36 pm 
Newbie

Joined: Mon Feb 14, 2005 10:11 am
Posts: 10
Location: Italy
Sorry, it was a mistake, I'm a new user of hibernate and I'm trying to understand how its work.

Now the query work correctly

Thank you

_________________
Ing. Marco Rinaldi - Italy


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