| Issue:
Hibernate calls a setter whose argument is of type <Interface Name> with an instance whose type name identifier, as viewed from the Eclipse debugger, is the name of an abstract super class prefixed to the magic string "$$EnhancerByCGLIB$$..". An IllegalArgumentException is then thrown, although the setter parameter instance does implement the interface excepting any cglib involvement. I would like the setter call to "just work."
 
 This happens during a call to createCriteria().list(). Here is a snippet of console output:
 
 Aug 11, 2006 5:56:31 PM org.hibernate.property.BasicPropertyAccessor$BasicSetter set
 SEVERE: IllegalArgumentException in class: hiver.Abstract, setter method of property: parent
 Aug 11, 2006 5:56:31 PM org.hibernate.property.BasicPropertyAccessor$BasicSetter set
 SEVERE: expected type: hiver.IFolder, actual value: hiver.Item$$EnhancerByCGLIB$$31d10f79
 
 
 Hibernate version:
 3.1.3
 
 
 Mapping documents:
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC
 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
 <hibernate-mapping package="hiver">
 
 <class name="Abstract">
 
 <id name="id" column="A_ID">
 <generator class="native"/>
 </id>
 
 <many-to-one name="parent" class="Item" not-null="true" />
 
 <joined-subclass name="Concrete">
 <key column="A_ID"/>
 </joined-subclass>
 
 </class>
 
 </hibernate-mapping>
 
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC
 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
 <hibernate-mapping package="hiver">
 
 <class name="Item">
 
 <id name="id" column="ITEM_ID">
 <generator class="native"/>
 </id>
 
 <joined-subclass name="Folder">
 <key column="ITEM_ID"/>
 </joined-subclass>
 
 <joined-subclass name="RootFolder">
 <key column="ITEM_ID" />
 </joined-subclass>
 
 </class>
 
 </hibernate-mapping>
 
 
 Code between sessionFactory.openSession() and session.close():
 // Create a relationship
 s = sessionFactory.openSession();
 
 RootFolder r = new RootFolder();
 s.save(r);
 Concrete i = new Concrete();
 i.setParent(r);
 s.save(i);
 
 s.close();
 
 // Test!
 s = sessionFactory.openSession();
 s.createCriteria( Abstract.class ).list(); // Calling list() exposes the issue
 s.close();
 
 
 
 Full stack trace of any exception that occurs:
 org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of hiver.Abstract.parent
 at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
 at org.hibernate.tuple.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:330)
 at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:188)
 at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3232)
 at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
 at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
 at org.hibernate.loader.Loader.doQuery(Loader.java:717)
 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
 at org.hibernate.loader.Loader.doList(Loader.java:2145)
 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
 at org.hibernate.loader.Loader.list(Loader.java:2024)
 at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
 at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
 at hiver.UseCaseTest.testUseCase(UseCaseTest.java:38)
 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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
 Caused by: java.lang.IllegalArgumentException: argument type mismatch
 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 org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
 ... 32 more
 
 
 
 Name and version of the database you are using:
 Reproducible with the following databases:
 
 HSQLDB version 1.8.0.4, and
 MySQL Ver 14.12 Distrib 5.0.24, for apple-darwin8.5.1 (i686) using readline 5.0
 
 and the following JDKs:
 
 Sun's Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) (Ubuntu Breezy), and
 Apple-vended Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-112) (Apple Mac OS X 10.4.7)
 
 
 The generated SQL (show_sql=true):
 Hibernate: insert into Item values ( )
 Hibernate: insert into RootFolder (ITEM_ID) values (?)
 Hibernate: insert into Abstract (parent) values (?)
 Hibernate: insert into Concrete (A_ID) values (?)
 Hibernate: select this_.A_ID as A1_3_0_, this_.parent as parent3_0_, case when this_1_.A_ID is not null then 1 when this_.A_ID is not null then 0 end as clazz_0_ from Abstract this_ left outer join Concrete this_1_ on this_.A_ID=this_1_.A_ID
 
 Debug level Hibernate log excerpt:
 
 
 |