Hibernate version:2.1.6
Mapping documents:
-------
Move
-------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.cmacgm.data">
<class name="Move" table="UNITHIST">
<composite-id name="id" class="MovePK">
<key-property name="moveUmid" column="UHUMID" type="java.lang.Integer" length="9"/>
<key-property name="moveAdat" column="UHADAT" type="java.sql.Timestamp" length="7"/>
<key-property name="moveAtim" column="UHATIM" type="java.lang.Integer" length="4"/>
</composite-id>
<property name="moveLine" type="java.lang.String" column="UHLINE" length="36"/>
<!-- Associations -->
<many-to-one name="poo" class="Port" update="false" insert="false" cascade="true">
<column name="UHPOO" not-null="true" />
</many-to-one>
<many-to-one name="pol" class="Port" update="false" insert="false" cascade="true">
<column name="UHPOL" not-null="true" />
</many-to-one>
<many-to-one name="pod" class="Port" update="false" insert="false" cascade="true">
<column name="UHPOD" not-null="true" />
</many-to-one>
<many-to-one name="fpd" class="Port" update="false" insert="false" cascade="true">
<column name="UHFPD" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
-------
Port
-------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.cmacgm.data">
<class name="Port" table="PORT">
<id name="id" type="java.lang.String" column="PRPORT">
<generator class="assigned" />
</id>
<property name="prname" type="java.lang.String" column="PRNAME" length="105"/>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
11:24:25,741 DEBUG EntityPersister:416 - Materializing entity: [com.cmacgm.data.Port# ]
11:24:25,741 DEBUG BatcherImpl:200 - about to open: 0 open PreparedStatements, 0 open ResultSets
11:24:25,741 DEBUG SQL:226 - select port0_.PRPORT as PRPORT1_, port0_.PRNAME as PRNAME1_, port0_.PRLCC as PRLCC1_, port0_.PRCOUNTRY as PRCOUNTRY1_, country1_.CNCOUNTRY as CNCOUNTRY0_, country1_.CNNAME as CNNAME0_ from PORT port0_ left outer join COUNTRY country1_ on port0_.PRCOUNTRY=country1_.CNCOUNTRY where port0_.PRPORT=?
11:24:25,741 DEBUG BatcherImpl:249 - preparing statement
11:24:25,741 DEBUG StringType:46 - binding ' ' to parameter: 1
11:24:25,741 DEBUG Loader:277 - processing result set
11:24:25,741 DEBUG Loader:294 - done processing result set (0 rows)
11:24:25,741 DEBUG BatcherImpl:207 - done closing: 0 open PreparedStatements, 0 open ResultSets
11:24:25,741 DEBUG BatcherImpl:269 - closing statement
11:24:25,741 DEBUG Loader:314 - total objects hydrated: 0
11:24:25,741 ERROR PersistentCollection:198 - Failed to lazily initialize a collection
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: , of class: com.cmacgm.data.Port
at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1954)
Name and version of the database you are using:
Oracle9i
The generated SQL (show_sql=true):
select port0_.PRPORT as PRPORT1_, port0_.PRNAME as PRNAME1_, port0_.PRLCC as PRLCC1_, port0_.PRCOUNTRY as PRCOUNTRY1_, country1_.CNCOUNTRY as CNCOUNTRY0_, country1_.CNNAME as CNNAME0_ from PORT port0_ left outer join COUNTRY country1_ on port0_.PRCOUNTRY=country1_.CNCOUNTRY where port0_.PRPORT=?
Question :
My Move object has 4 ports objects. I use the cascading mode to retrieve the ports associated to a Move when I do a query on the move table.
But sometimes one key of this table, poiting to the port table, is null ...
So hibernate is trying to query the table port with a null key.
How can I avoid this problem ?
Thanks in advance for your help,
Regards
Jean-Guillaume LALANNE
[jean_gui at yahoo dot fr]
|