-->
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.  [ 2 posts ] 
Author Message
 Post subject: problem with left join fetch
PostPosted: Thu Sep 11, 2008 5:19 pm 
Beginner
Beginner

Joined: Mon Jul 09, 2007 2:21 pm
Posts: 24
i have the following tables

Table1
ID
NAME

Table2
ID
DESCR
TABLE1_ID NULLABLE, Foreign key referencing ID of Table1



Hql: from Table1 rs left join fetch rs.table2 sgms


A null pointer exception is thrown when executing the above hql...but if i remove "fetch" from the hql statement it works fine.

Can you help me resolve this?

Table1.hbm.xml
----------
----------
<set name="Table2" inverse="true">
<key>
<column name="TABLE1_ID" precision="22" scale="0" />
</key>

<one-to-many class="com.mavent.model.Table1" />
</set>



Table2.hbm.xml

----------------
---------------
<many-to-one name="Table1" class="com.mavent.model.Table1" fetch="select">

<column name="TABLE1_ID" precision="22" scale="0" />
</many-to-one>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2008 6:27 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
I believe the problem is the ID of your main table (Table1) being nullable.

Just to prove that this is the case, remove those row(s) of table 1 having the ID = null (I would expect to be only 1), and then rerun the query with "left join fetch".

_________________
Gonzalo Díaz


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