-->
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.  [ 1 post ] 
Author Message
 Post subject: Error during refactoring of class hierarchy
PostPosted: Fri May 14, 2010 5:15 pm 
Newbie

Joined: Fri May 14, 2010 4:34 pm
Posts: 1
Hi,

I'm in the process of re-factoring the table per class hierarchy to a table per subclass. Keeping all the associations the way they are.. all I did was to change the <subclass>..</subclass> tags to <joined-subclass>...</joined-subclass>

this is the code snippet from a larger hbm.xml (cannot put the whole file here)
Old:
Code:
<subclass
            name="com.....A"
            discriminator-value="...."
        >

New:
Code:
        <joined-subclass
            name="com.....A"
        >
            <key
                column="ID"
            />



When I run the an integration test (with an hsqldb database) the whole class hierarchy persists and there is no problem. However, this class has a one-to-many list association with another class. This association is described by
Code:
<joined-subclass
            name="com.....A"
        >
            <key
                column="ID"
            />
            <many-to-one.../>
            <property .../>
            <!-- other mappings.. -->
           
        <list
            name="values"
            table="Values"
            lazy="false"
            cascade="all-delete-orphan"
        >
            <cache
                usage="read-write"
            />

            <key
                column="...A.id"
            >
            </key>

            <index
                column="..."
            />

            <one-to-many
                  class="com..C"
            />

        </list>

Quote:
I purposefully renamed the class names and tables names .. due to some constraints at work..

There is no difference in this mapping from the old (<subclass>) mapping strategy to the new (<joined-subclass>) strategy.

When I persist an instance of class A without the collection of values it does so without any problems for both the <subclass> and <joined-subclass> configurations. When I persist the instance of class A with the collection of values, I get no errors for <subclass>. When I started doing the re-engineering of the subclassing strategy to table per subclass using the <joined-subclass> and when I persist using the collection of values, I get the following error.

I should also say that I come from an ancient version of hibernate (3.1) and due to other constraints we were not able to uplift a particular project to the latest versions. The mappings were generated by xdoclet notation in the domain objects.

Quote:
Environment
JUnit; hibernate3.1; hsqldb-1.8; spring-2.1;


Code:
WARN - SQL Error: 0, SQLState: null
ERROR - failed batch
ERROR - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:555)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
   at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:117)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy50.saveOrUpdateObject(Unknown Source)
   at com......ServiceIntegrationTest.java:550)
   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:597)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
   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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.BatchUpdateException: failed batch
   at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
   at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
   at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
   ... 33 mor



I've been debugging this code for the past couple of days.. reading the various posts, blogs.. but nothing seem to help me in fixing this problem.

I really appreciate if someone could give me a hand in this one..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.