I'm getting an exception for a joined subclass
Hibernate version: 2.1.8
Mapping documents: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
>
<class
name="com.opodo.backoffice.objects.ProductTrip"
table="otp_pr_trip"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<id
name="oid"
column="oid"
type="int"
>
<generator class="increment">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ProductTrip.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="creationTime"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="CREATION_TIME"
/>
<property
name="lastModifiedTime"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="LAST_MOD_TIME"
/>
<property
name="tripName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="TRIP_NAME"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ProductTrip.xml
containing the additional properties and place it in your merge dir.
-->
<joined-subclass
name="com.opodo.backoffice.objects.CarTrip"
table="otp_pr_trp_booked_car_chd"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="OID"
/>
<property
name="bookedCarId"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_ID"
/>
<many-to-one
name="traveller"
class="com.opodo.backoffice.objects.ProductTraveller"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
property-ref="travellerId"
column="BOOKED_CAR_DRIVER_ID"
/>
<many-to-one
name="pickupCarLocation"
class="com.opodo.backoffice.objects.CarLocation"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
property-ref="oagCode"
column="BOOKED_CAR_PICKUP_LOC_CODE"
/>
<many-to-one
name="pickupOagLocation"
class="com.opodo.backoffice.objects.OAGLocation"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
property-ref="locationCode"
column="BOOKED_CAR_PICKUP_LOC_CODE"
/>
<property
name="bookedCarAddedDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_ADDED_DATE"
/>
<property
name="bookedCarCompanyCode"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_COMPANY_CODE"
/>
<property
name="bookedCarHireType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_HIRE_TYPE"
/>
<property
name="bookedCarLocalCurrency"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_LOCAL_CURRENCY"
/>
<property
name="bookedCarPickupDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_PICKUP_DATE"
/>
<property
name="bookedCarPickupLocCode"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_PICKUP_LOC_CODE"
/>
<property
name="bookedCarPickupLocName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_PICKUP_LOC_NAME"
/>
<property
name="bookedCarPickupTime"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_PICKUP_TIME"
/>
<property
name="bookedCarPriceEuros"
type="java.math.BigDecimal"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_PRICE_EUROS"
/>
<property
name="bookedCarRecordLocator"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_RECORD_LOCATOR"
/>
<property
name="bookedCarReturnDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_RETURN_DATE"
/>
<property
name="bookedCarReturnLocCode"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_RETURN_LOC_CODE"
/>
<property
name="bookedCarReturnLocName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_RETURN_LOC_NAME"
/>
<property
name="bookedCarReturnTime"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_RETURN_TIME"
/>
<property
name="bookedCarRowId"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_ROW_ID"
/>
<property
name="bookedCarStatus"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_STATUS"
/>
<property
name="bookedCarTypeCode"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_TYPE_CODE"
/>
<property
name="bookedCarTypeName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BOOKED_CAR_TYPE_NAME"
/>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): Session session = sessionFactory.openSession(); Iterator cars = session.iterate("from CarTrip as carTrip"); session.close();
Full stack trace of any exception that occurs: net.sf.hibernate.HibernateException: More than one row with the given identifier was found: 32042, for class: com.opodo.backoffice.objects.CarTrip
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:71)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.NormalizedEntityPersister.load(NormalizedEntityPersister.java:398)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2131)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2001)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1963)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:208)
at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:130)
at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:93)
at net.sf.hibernate.impl.IteratorImpl.<init>(IteratorImpl.java:64)
at net.sf.hibernate.hql.QueryTranslator.iterate(QueryTranslator.java:869)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1619)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1592)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1584)
at com.opodo.backoffice.jobserver.ThreadedFBOService.aceCarsProcessing(ThreadedFBOService.java:115)
at com.opodo.backoffice.jobserver.ThreadedFBOServiceTest.testAceCarsProcessingStringBoolean(ThreadedFBOServiceTest.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:536)
Name and version of the database you are using: Oracle 9.2i
The generated SQL (show_sql=true): Hibernate: select cartrip0_.OID as x0_0_ from otp_pr_trp_booked_car_chd cartrip0_ inner join otp_pr_trip cartrip0__1_ on cartrip0_.OID=cartrip0__1_.oid
Hibernate: select cartrip0_.OID as oid3_, cartrip0_.BOOKED_CAR_ID as BOOKED_C2_4_3_, cartrip0_.BOOKED_CAR_DRIVER_ID as BOOKED_C3_4_3_, cartrip0_.BOOKED_CAR_PICKUP_LOC_CODE as BOOKED_C4_4_3_, cartrip0_.BOOKED_CAR_ADDED_DATE as BOOKED_C5_4_3_, cartrip0_.BOOKED_CAR_COMPANY_CODE as BOOKED_C6_4_3_, cartrip0_.BOOKED_CAR_HIRE_TYPE as BOOKED_C7_4_3_, cartrip0_.BOOKED_CAR_LOCAL_CURRENCY as BOOKED_C8_4_3_, cartrip0_.BOOKED_CAR_PICKUP_DATE as BOOKED_C9_4_3_, cartrip0_.BOOKED_CAR_PICKUP_LOC_NAME as BOOKED_10_4_3_, cartrip0_.BOOKED_CAR_PICKUP_TIME as BOOKED_11_4_3_, cartrip0_.BOOKED_CAR_PRICE_EUROS as BOOKED_12_4_3_, cartrip0_.BOOKED_CAR_RECORD_LOCATOR as BOOKED_13_4_3_, cartrip0_.BOOKED_CAR_RETURN_DATE as BOOKED_14_4_3_, cartrip0_.BOOKED_CAR_RETURN_LOC_CODE as BOOKED_15_4_3_, cartrip0_.BOOKED_CAR_RETURN_LOC_NAME as BOOKED_16_4_3_, cartrip0_.BOOKED_CAR_RETURN_TIME as BOOKED_17_4_3_, cartrip0_.BOOKED_CAR_ROW_ID as BOOKED_18_4_3_, cartrip0_.BOOKED_CAR_STATUS as BOOKED_19_4_3_, cartrip0_.BOOKED_CAR_TYPE_CODE as BOOKED_20_4_3_, cartrip0_.BOOKED_CAR_TYPE_NAME as BOOKED_21_4_3_, cartrip0__1_.CREATION_TIME as CREATION2_3_3_, cartrip0__1_.LAST_MOD_TIME as LAST_MOD3_3_3_, cartrip0__1_.TRIP_NAME as TRIP_NAME3_3_, producttra1_.OID as OID0_, producttra1_.TRAVELLER_ID as TRAVELLE2_0_, producttra1_.EMAIL_ADDRESS as EMAIL_AD3_0_, producttra1_.FIRST_NAME as FIRST_NAME0_, producttra1_.STORE_ID as STORE_ID0_, producttra1_.SURNAME as SURNAME0_, producttra1_.TELEPHONE_NUMBER as TELEPHON7_0_, producttra1_.TITLE as TITLE0_, carlocatio2_.id as id1_, carlocatio2_.COUNTRY_CODE as COUNTRY_2_1_, carlocatio2_.OAG_CODE as OAG_CODE1_, oaglocatio3_.id as id2_, oaglocatio3_.COUNTRY_CODE as COUNTRY_2_2_, oaglocatio3_.LOCATION_CODE as LOCATION3_2_ from otp_pr_trp_booked_car_chd cartrip0_ inner join otp_pr_trip cartrip0__1_ on cartrip0_.OID=cartrip0__1_.oid left outer join otp_pr_traveller producttra1_ on cartrip0_.BOOKED_CAR_DRIVER_ID=producttra1_.TRAVELLER_ID left outer join otp_car_location carlocatio2_ on cartrip0_.BOOKED_CAR_PICKUP_LOC_CODE=carlocatio2_.OAG_CODE left outer join otp_sa_oag_locations oaglocatio3_ on cartrip0_.BOOKED_CAR_PICKUP_LOC_CODE=oaglocatio3_.LOCATION_CODE where cartrip0_.OID=?
Hibernate: select producttra0_.OID as OID0_, producttra0_.TRAVELLER_ID as TRAVELLE2_0_, producttra0_.EMAIL_ADDRESS as EMAIL_AD3_0_, producttra0_.FIRST_NAME as FIRST_NAME0_, producttra0_.STORE_ID as STORE_ID0_, producttra0_.SURNAME as SURNAME0_, producttra0_.TELEPHONE_NUMBER as TELEPHON7_0_, producttra0_.TITLE as TITLE0_ from otp_pr_traveller producttra0_ where producttra0_.TRAVELLER_ID=?
Hibernate: select carlocatio0_.id as id0_, carlocatio0_.COUNTRY_CODE as COUNTRY_2_0_, carlocatio0_.OAG_CODE as OAG_CODE0_ from otp_car_location carlocatio0_ where carlocatio0_.OAG_CODE=?
Hibernate: select oaglocatio0_.id as id0_, oaglocatio0_.COUNTRY_CODE as COUNTRY_2_0_, oaglocatio0_.LOCATION_CODE as LOCATION3_0_ from otp_sa_oag_locations oaglocatio0_ where oaglocatio0_.LOCATION_CODE=?
Debug level Hibernate log excerpt: [Loader ] DEBUG - result row: 1331
[Loader ] DEBUG - done processing result set (1 rows)
[BatcherImpl ] DEBUG - done closing: 1 open PreparedStatements, 1 open ResultSets
[BatcherImpl ] DEBUG - closing statement
[Loader ] DEBUG - total objects hydrated: 0
[BatcherImpl ] DEBUG - about to open: 1 open PreparedStatements, 1 open ResultSets
[SQL ] DEBUG - select oaglocatio0_.id as id0_, oaglocatio0_.COUNTRY_CODE as COUNTRY_2_0_, oaglocatio0_.LOCATION_CODE as LOCATION3_0_ from otp_sa_oag_locations oaglocatio0_ where oaglocatio0_.LOCATION_CODE=?
Hibernate: select oaglocatio0_.id as id0_, oaglocatio0_.COUNTRY_CODE as COUNTRY_2_0_, oaglocatio0_.LOCATION_CODE as LOCATION3_0_ from otp_sa_oag_locations oaglocatio0_ where oaglocatio0_.LOCATION_CODE=?
[BatcherImpl ] DEBUG - preparing statement
[StringType ] DEBUG - binding 'LHR' to parameter: 1
[Loader ] DEBUG - processing result set
[IntegerType ] DEBUG - returning '4310' as column: id0_
[Loader ] DEBUG - result row: 4310
[Loader ] DEBUG - done processing result set (1 rows)
[BatcherImpl ] DEBUG - done closing: 1 open PreparedStatements, 1 open ResultSets
[BatcherImpl ] DEBUG - closing statement
[Loader ] DEBUG - total objects hydrated: 0
[SessionImpl ] DEBUG - done materializing entity [com.opodo.backoffice.objects.CarTrip#32042]
[SessionImpl ] DEBUG - resolving associations for [com.opodo.backoffice.objects.ProductTraveller#32043]
[SessionImpl ] DEBUG - done materializing entity [com.opodo.backoffice.objects.ProductTraveller#32043]
[SessionImpl ] DEBUG - initializing non-lazy collections
[ThreadedFBOService ] WARN - Database error.
|