-->
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: Maps with composite elements broken in Hibernate 2.1.3?
PostPosted: Mon May 10, 2004 7:14 am 
Regular
Regular

Joined: Tue Oct 07, 2003 10:20 am
Posts: 77
I've just upgraded from Hibernate 2.1.2 to Hibernate 2.1.3, and am experiencing an issue with a mapping for a Map with a composite-element.

When doing an update on my parent object, an exception is thrown that didn't occur in version 2.1.2. However, this exception is only thrown if you use the saveOrUpdateCopy method on the session (which I need for another association, but has been deleted from my simple test case to try simplify the problem).

I was just wondering if anyone else has seen this issue? The copy of the simple test case is available if that helps.

My mapping document is as follows:

Code:
<?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>
    <class name="com.qxlva.bo.Person" table="PERSON" dynamic-update="false" dynamic-insert="false">

        <id name="id" column="PERSON_ID" type="int" unsaved-value="0">
            <generator class="native">
            </generator>
        </id>

        <property name="name" type="string" update="true" insert="true" access="property" column="FULL_NAME" length="20"/>

        <map name="ownedCars" table="OWNED_CARS" lazy="false" sort="unsorted" inverse="false" cascade="none">

            <key column="PERSON_ID"/>

            <index-many-to-many class="com.qxlva.bo.Car" column="CAR_ID"/>

            <composite-element class="com.qxlva.bo.CarDetails">
                <property name="numberPlate" type="string" update="true" insert="true" access="property" column="NUMBER_PLATE" length="10" not-null="true"/>
                <property name="colour" type="string" update="true" insert="true" access="property" column="COLOUR" length="20" not-null="true"/>
                <property name="carTaxDue" type="calendar" update="true" insert="true" access="property" column="CAR_TAX_DUE_DATE" not-null="true"/>
                <property name="secondHand" type="yes_no" update="true" insert="true" access="property" column="SECOND_HAND"/>
            </composite-element>

        </map>

    </class>

</hibernate-mapping>


My java code for updating is:

Code:
Session hibernateSession = factory.openSession();

Transaction trans = hibernateSession.beginTransaction();

if (updateWithCopy())
{
    hibernateSession.saveOrUpdateCopy(objectToUpdate);
}
else
{
    hibernateSession.saveOrUpdate(objectToUpdate);
}

trans.commit();

hibernateSession.flush();
hibernateSession.close();


The log with the stack trace of the exception is as follows (I've set hibernate.cglib.use_reflection_optimizer to false, to obtain the exception):

Code:
12:06:02,671 DEBUG SQL:237 - select car0_.CAR_ID as CAR_ID0_, car0_.CAR_NAME as CAR_NAME0_, car0_.MODEL as MODEL0_ from CAR car0_ where car0_.CAR_ID=?
Hibernate: select car0_.CAR_ID as CAR_ID0_, car0_.CAR_NAME as CAR_NAME0_, car0_.MODEL as MODEL0_ from CAR car0_ where car0_.CAR_ID=?
12:06:02,681 DEBUG BatcherImpl:241 - preparing statement
12:06:02,681 DEBUG IntegerType:46 - binding '55' to parameter: 1
12:06:02,691 DEBUG Loader:197 - processing result set
12:06:02,691 DEBUG Loader:405 - result row: 55
12:06:02,691 DEBUG Loader:536 - Initializing object from ResultSet: 55
12:06:02,701 DEBUG Loader:605 - Hydrating entity: com.qxlva.bo.Car#55
12:06:02,701 DEBUG StringType:68 - returning 'Punto 18' as column: CAR_NAME0_
12:06:02,711 DEBUG StringType:68 - returning 'GTI Turbo 18' as column: MODEL0_
12:06:02,711 DEBUG Loader:226 - done processing result set (1 rows)
12:06:02,731 DEBUG BatcherImpl:203 - done closing: 1 open PreparedStatements, 1 open ResultSets
12:06:02,731 DEBUG BatcherImpl:261 - closing statement
12:06:02,741 DEBUG Loader:239 - total objects hydrated: 1
12:06:02,741 DEBUG SessionImpl:2191 - resolving associations for [com.qxlva.bo.Car#55]
12:06:02,751 DEBUG SessionImpl:2215 - done materializing entity [com.qxlva.bo.Car#55]
12:06:02,761 DEBUG Loader:226 - done processing result set (2 rows)
12:06:02,761 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
12:06:02,771 DEBUG BatcherImpl:261 - closing statement
12:06:02,771 DEBUG SessionImpl:3068 - 1 collections were found in result set
12:06:02,781 DEBUG SessionImpl:3086 - collection fully initialized: [com.qxlva.bo.Person.ownedCars#56]
12:06:02,781 DEBUG SessionImpl:3089 - 1 collections initialized
12:06:02,791 DEBUG SessionImpl:3260 - collection initialized
12:06:02,801 DEBUG Cascades:312 - id unsaved-value: 0
12:06:02,811 DEBUG SessionImpl:1975 - loading [com.qxlva.bo.Car#54]
12:06:02,811 DEBUG SessionImpl:2072 - attempting to resolve [com.qxlva.bo.Car#54]
12:06:02,821 DEBUG SessionImpl:2088 - resolved object in session cache [com.qxlva.bo.Car#54]
java.lang.NullPointerException
   at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:96)
   at net.sf.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:179)
   at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:205)
   at net.sf.hibernate.type.ComponentType.copy(ComponentType.java:285)
   at net.sf.hibernate.type.MapType.copy(MapType.java:52)
   at net.sf.hibernate.type.TypeFactory.copy(TypeFactory.java:284)
   at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:4033)
   at net.sf.hibernate.impl.SessionImpl.saveOrUpdateCopy(SessionImpl.java:3971)
   at com.qxlva.dao.BaseDao.update(BaseDao.java:81)
   at com.qxlva.dao.BaseDaoTest.testUpdate(BaseDaoTest.java:355)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at com.intellij.rt.execution.junit2.JUnitStarter.main(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at com.intellij.rt.execution.application.AppMain.main(Unknown Source)


The database is Oracle 9.2.0.4.

I did a check to make sure it wasn't one of the utility JARs causing the problem, but the issue goes away if you use the 2.1.2 version of the Hibernate JAR file.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2004 12:30 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Please provide a simple workable testcase into JIRA.

_________________
Emmanuel


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.