-->
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: Rows values loaded but nothing hydrated - no PK [FIXED]
PostPosted: Wed Apr 11, 2007 3:22 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
Hello,

version: Hibernate 3.1.3

We used Database Explorer to reverse engineer a table with no primary keys. D.E. has generated two classes MyClass and MyClassId and one mapping which is shown below:

Code:
?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
    <class name="foo.MyClass" table="TABLE1" schema="USER1" lazy="false" >
        <composite-id name="id" class="foo.MyClassId">
            <key-property name="prop1" type="java.lang.String">
                <column name="PROP1" length="4" />
            </key-property>
            <key-property name="prop2" type="java.lang.Long">
                <column name="PROP2" precision="5" scale="0" />
            </key-property>
            <key-property name="prop3" type="java.lang.String">
                <column name="PROP3" length="1" />
            </key-property>
            <key-property name="prop4" type="java.lang.String">
                <column name="PROP4" length="8" />
            </key-property>
            <key-property name="prop5" type="java.lang.String">
                <column name="PROP5" length="1" />
            </key-property>
            <key-property name="prop6" type="java.lang.String">
                <column name="PROP6" length="1" />
            </key-property>
            <key-property name="prop7" type="timestamp">
                <column name="PROP7" length="7" />
            </key-property>
            <key-property name="prop8" type="java.lang.String">
                <column name="PROP8" length="3" />
            </key-property>
            <key-property name="prop9" type="java.lang.String">
                <column name="PROP9" length="8" />
            </key-property>
            <key-property name="prop10" type="java.lang.String">
                <column name="PROP10" length="16" />
            </key-property>
            <key-property name="prop11" type="java.lang.String">
                <column name="PROP11" length="600" />
            </key-property>
            <key-property name="prop12" type="timestamp">
                <column name="PROP12" length="7" />
            </key-property>
            <key-property name="prop13" type="timestamp">
                <column name="PROP13" length="7" />
            </key-property>
            <key-property name="prop14" type="java.lang.String">
                <column name="PROP14" length="8" />
            </key-property>
        </composite-id>
    </class>
</hibernate-mapping>


When we do a query like this:
from MyClass h fetch all properties where h.id.prop1 = ? and h.id.prop2 = ? and h.id.prop3 = ? and h.id.prop4= ?

Hibernate finds matching rows but does not hydrate:

Code:
5437 [main] DEBUG org.hibernate.loader.Loader  - processing result set
5437 [main] DEBUG org.hibernate.loader.Loader  - result set row: 0
5437 [main] DEBUG org.hibernate.type.StringType  - returning '06' as column: xxx
5437 [main] DEBUG org.hibernate.type.LongType  - returning '31215' as column: xxx
5437 [main] DEBUG org.hibernate.type.StringType  - returning '6' as column: xxx
5437 [main] DEBUG org.hibernate.type.StringType  - returning 'ABCDE' as column: xxx
5453 [main] DEBUG org.hibernate.type.StringType  - returning '0' as column: xxx
5453 [main] DEBUG org.hibernate.type.StringType  - returning 'C' as column: xxx
5468 [main] DEBUG org.hibernate.type.TimestampType  - returning '2006-07-17 11:30:18' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning 'V' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning 'XYZ' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning null as column: xxx
5468 [main] DEBUG org.hibernate.loader.Loader  - result row: null
5468 [main] DEBUG org.hibernate.loader.Loader  - result set row: 1
5468 [main] DEBUG org.hibernate.type.StringType  - returning '06' as column: xxx
5468 [main] DEBUG org.hibernate.type.LongType  - returning '31215' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning '6' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning 'FGHIJ' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning '0' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning 'O' as column: xxx
5468 [main] DEBUG org.hibernate.type.TimestampType  - returning '2007-04-10 14:26:21' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning 'V' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning 'ORDON_01' as column: xxx
5468 [main] DEBUG org.hibernate.type.StringType  - returning null as column: xxx
5468 [main] DEBUG org.hibernate.loader.Loader  - result row: null
5468 [main] DEBUG org.hibernate.loader.Loader  - done processing result set (2 rows)
5468 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close ResultSet (open ResultSets: 1, globally: 1)
5468 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
5468 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - closing statement
5484 [main] DEBUG org.hibernate.loader.Loader  - total objects hydrated: 0


Any idea ?
Thanks.
Denis.


Last edited by denis.etienne on Wed Apr 11, 2007 4:19 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 11, 2007 4:17 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
Whenever Hibernate encounters null value for a column which belong to the composite key, it discard the row and doesn't hydrate corresponding object.

All column included in the the composite key should be made not nullable.

_________________
Denis
Don't forget to rate ... thanks.


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.