-->
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: Exception when saving objects with many-to-many relation
PostPosted: Sat Jan 01, 2005 1:00 pm 
Newbie

Joined: Sat Jan 01, 2005 12:34 pm
Posts: 1
Hibernate version: 2.1.7

I have a strange exception with a many-to-many mapping when saving my objects.

I have a user class with a list of projects and and project class with a list of users.

Mapping documents:

Project:

<hibernate-mapping>

<class name="com.pm.core.domain.project.BasicProjectImpl" table="PROJECT">

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

<version column="VERSION" name="Version" type="long" />

<property name="code" column="CODE" type="string" not-null="true" />
<property name="name" column="NAME" type="string" not-null="true" />

<set name="members" table="member" cascade="none" lazy="false">
<key column="ID" />
<many-to-many column="PMU_ID" class="com.pm.core.domain.UserImpl" outer-join="false"/>
</set>

</class>


User :


<class name="com.pm.core.domain.UserImpl" table="PMUSER">

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

<version column="VERSION" name="Version" type="long" />

<property column="PWD" length="10" name="Password" not-null="true" type="string" />
<property column="LOGIN" length="10" name="Login" not-null="true" type="string" />
<property column="LASTNAME" length="100" name="LastName" not-null="false" type="string" />
<property column="FIRSTNAME" length="100" name="FirstName" not-null="false" type="string" />
<property column="EMAIL" length="50" name="Email" not-null="true" type="string" />

<many-to-one class="com.pm.core.domain.CompanyImpl" name="Company"
outer-join="true" cascade="none" update="false" insert="false">
<column name="COM_ID" />
</many-to-one>

<set name="projects" table="member" cascade="none" lazy="false">
<key column="PMU_ID" />
<many-to-many column="ID" class="com.pm.core.domain.project.BasicProjectImpl" outer-join="false"/>
</set>

</class>




Full stack trace of any exception that occurs:

When saving a project the trace is:

org.springframework.orm.hibernate.HibernateSystemException: IllegalArgumentException occurred calling getter of com.pm.core.domain.project.BasicProjectImpl.id; nested exception is net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.pm.core.domain.project.BasicProjectImpl.id
net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.pm.core.domain.project.BasicProjectImpl.id
at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:110)
at net.sf.hibernate.persister.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:315)
at net.sf.hibernate.proxy.HibernateProxyHelper.getIdentifier(HibernateProxyHelper.java:48)
at net.sf.hibernate.type.EntityType.toString(EntityType.java:84)
at net.sf.hibernate.type.PersistentCollectionType.toString(PersistentCollectionType.java:82)
at net.sf.hibernate.impl.Printer.toString(Printer.java:49)
at net.sf.hibernate.impl.Printer.toString(Printer.java:82)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2301)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:464)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:376)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:242)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy0.add(Unknown Source)
at com.pm.core.data.UserMapperTest.testAddWithoutConcurrencyFailureException(UserMapperTest.java:123)
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:585)
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 junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
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:585)
at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:96)
... 34 more




When saving a user the trace is:


org.springframework.orm.hibernate.HibernateSystemException: IllegalArgumentException occurred calling getter of com.pm.core.domain.UserImpl.Id; nested exception is net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.pm.core.domain.UserImpl.Id
net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.pm.core.domain.UserImpl.Id
at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:110)
at net.sf.hibernate.persister.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:315)
at net.sf.hibernate.proxy.HibernateProxyHelper.getIdentifier(HibernateProxyHelper.java:48)
at net.sf.hibernate.type.EntityType.toString(EntityType.java:84)
at net.sf.hibernate.type.PersistentCollectionType.toString(PersistentCollectionType.java:82)
at net.sf.hibernate.impl.Printer.toString(Printer.java:49)
at net.sf.hibernate.impl.Printer.toString(Printer.java:82)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2301)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:464)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:376)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:242)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy3.add(Unknown Source)
at com.pm.core.data.poject.BasicProjectMapperTest.testAddWithoutConcurrencyFailureException(BasicProjectMapperTest.java:101)
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:585)
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 junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@739f3f
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:96)
... 34 more


Name and version of the database you are using:

MySQL 4.1.18

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: object is not an instance of declaring class
PostPosted: Sun Jan 23, 2005 4:42 am 
Newbie

Joined: Sat Mar 27, 2004 4:31 am
Posts: 5
Location: Kuala Lumpur
I'm having the samething, I think is a misconfiguration of abstract class and/or inheritance which may be causing the problem


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.