-->
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: query returns list with 1 element: null
PostPosted: Mon Nov 28, 2005 3:28 pm 
Newbie

Joined: Mon Nov 28, 2005 2:35 pm
Posts: 14
Hi!
I have the following problem: When quering an association table, I get a list containing one element (this is correct, since there is only one entry in the table BEZ_SLA_WVGRUND). But when accessing the element at index 0, it turns out to be a null. Well, since the hibernate queries always worked fine for non-association tables, I guess, that somewhere there lies the problem. Would someone be so kind and tell me what I am doing wrong?

Thx in advance


Hibernate version:
version 3.1 rc2
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="auster.table.BezSlaWvgrund" table="BEZ_SLA_WVGRUND" schema="Test">
<composite-id name="id" class="auster.table.BezSlaWvgrundId">
<key-many-to-one name="sla" class="auster.table.Sla">
<column name="SLA_MID" precision="11" scale="0" />
</key-many-to-one>
<key-many-to-one name="wvgrund" class="auster.table.Wvgrund">
<column name="WVGRUND_MID" precision="11" scale="0" />
</key-many-to-one>
<key-property name="kommentarfeldJn" type="boolean">
<column name="KOMMENTARFELD_JN" precision="1" scale="0" />
</key-property>
<key-property name="kommentarfeldPflichtJn" type="boolean">
<column name="KOMMENTARFELD_PFLICHT_JN" precision="1" scale="0" />
</key-property>
<key-property name="wvVorschlagTage" type="long">
<column name="WV_VORSCHLAG_TAGE" precision="11" scale="0" />
</key-property>
<key-property name="wvVorschlagStunden" type="long">
<column name="WV_VORSCHLAG_STUNDEN" precision="11" scale="0" />
</key-property>
<key-property name="aktivStatus" type="boolean">
<column name="AKTIV_STATUS" precision="1" scale="0" />
</key-property>
<key-many-to-one name="mitarbeiter" class="auster.table.Mitarbeiter">
<column name="ANLAGE_MA" precision="11" scale="0" />
</key-many-to-one>
<key-property name="anlageTs" type="timestamp">
<column name="ANLAGE_TS" length="7" />
</key-property>
<key-property name="gesperrtTs" type="timestamp">
<column name="GESPERRT_TS" length="7" />
</key-property>
<key-property name="gesperrtJn" type="big_decimal">
<column name="GESPERRT_JN" precision="22" scale="0" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
transaction = session.beginTransaction();
Query q2 = session.createQuery("from BezSlaWvgrund");
List reasons = q2.list();
System.out.println("reasons count. " + reasons.size());
BezSlaWvgrund test = (BezSlaWvgrund) reasons.get(0);
System.out.println("TEST TEST: " + test);
transaction.commit();
Full stack trace of any exception that occurs:
20:09:46,921 INFO [STDOUT] reasons count. 1
20:09:46,921 INFO [STDOUT] TEST TEST: null
Name and version of the database you are using:
Oracle 9
The generated SQL (show_sql=true):
20:09:46,921 INFO [STDOUT] Hibernate: select bezslawvgr1_.SLA_MID as SLA1_21_,
bezslawvgr1_.WVGRUND_MID as WVGRUND2_21_, bezslawvgr1_.KOMMENTARFELD_JN as KOMME
NTA3_21_, bezslawvgr1_.KOMMENTARFELD_PFLICHT_JN as KOMMENTA4_21_, bezslawvgr1_.W
V_VORSCHLAG_TAGE as WV5_21_, bezslawvgr1_.WV_VORSCHLAG_STUNDEN as WV6_21_, bezsl
awvgr1_.AKTIV_STATUS as AKTIV7_21_, bezslawvgr1_.ANLAGE_MA as ANLAGE8_21_, bezsl
awvgr1_.ANLAGE_TS as ANLAGE9_21_, bezslawvgr1_.GESPERRT_TS as GESPERRT10_21_, be
zslawvgr1_.GESPERRT_JN as GESPERRT11_21_ from AUSTER.SLA sla0_ inner join AUSTER
.BEZ_SLA_WVGRUND bezslawvgr1_ on sla0_.IDX=bezslawvgr1_.SLA_MID inner join AUSTE
R.WVGRUND wvgrund2_ on bezslawvgr1_.WVGRUND_MID=wvgrund2_.IDX


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 10:17 am 
Newbie

Joined: Mon Nov 28, 2005 2:35 pm
Posts: 14
I have found out, that the problem was, that one of the composite id's values has been null.


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.