Hibernate version: 3.0
Mapping documents:
Code:
<hibernate-mapping>
<class
name="com.mobilitysol.uy.check_manager.domain.CheckType"
table="CHECK_TYPE">
<id name="id" column="uid">
<generator class="uuid.hex"/>
</id>
<discriminator column="type_id"/>
<subclass
name="com.mobilitysol.uy.check_manager.domain.Defered"
discriminator-value="1">
<property
name="expireDate"
type="com.maiasoft.uy.pml.hibernate.DateOnlyType"/
>
</subclass>
<subclass
name="com.mobilitysol.uy.check_manager.domain.AtDay"
discriminator-value="2">
</subclass>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class
name="com.mobilitysol.uy.check_manager.domain.Check"
table="CHECKS">
<id name="id" column="uid">
<generator class="uuid.hex"/>
</id>
<discriminator column="type_id"/>
... irrelevant properties ...
... irrelevant many-to-one ...
<many-to-one
name="checkType"
column="checktype_uid"
class="com.mobilitysol.uy.check_manager.domain.CheckType"
cascade="delete"
/>
<subclass
name="com.mobilitysol.uy.check_manager.domain.Received"
discriminator-value="1">
... irrelevant properties ...
</subclass>
<subclass
name="com.mobilitysol.uy.check_manager.domain.Emitted"
discriminator-value="2">
<property name="checkBookNumber"/>
</subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():CheckType is abstract, and have an abstract method called getCheckType that return an integer, this method is implemented by Defered and by AtDay
Into a Check class i make this...
Code:
if (checkType.getCheckType() == CheckTypes.DEFFERED) {
...
... ((Defered) checkType) ...
...
}
I probe with instanceof too and the problem is the same. When i call getCheckType Deffered.getCheckType is called, but, then, i cast it to Deffered and i have the ClassCastException.
Full stack trace of any exception that occurs:Code:
java.lang.ClassCastException: com.mobilitysol.uy.check_manager.domain.CheckType$$EnhancerByCGLIB$$b2b60f2e
at com.mobilitysol.uy.check_manager.domain.Received.getCheckInfoHeavy(Received.java:132)
at com.mobilitysol.uy.check_manager.domain.managers.CheckManager.getCheckInfoHeavy(CheckManager.java:228)
at com.mobilitysol.uy.check_manager.domain.CheckMgtTest.testAgregarCheck(CheckMgtTest.java:186)
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.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)
Name and version of the database you are using:HSQLDB 1.7.3.3
The generated SQL (show_sql=true):Code:
Hibernate: insert into CHECK_TYPE (expireDate, type_id, uid) values (?, '1', ?)
Hibernate: insert into CHECKS (entryDate, emissionDate, rejectionDate, number, serie, holder, receiverName, cost, currency, state, rejectionReason, observation, accountNumber, subsidiary_uid, checktype_uid, applicationType, appliedDate, type_id, uid) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '1', ?)
Hibernate: update CHECKS set emitts_uid=? where uid=?
Hibernate: select check0_.uid as uid, check0_.entryDate as entryDate2_, check0_.emissionDate as emission4_2_, check0_.rejectionDate as rejectio5_2_, check0_.number as number2_, check0_.serie as serie2_, check0_.holder as holder2_, check0_.receiverName as receiver9_2_, check0_.cost as cost2_, check0_.currency as currency2_, check0_.state as state2_, check0_.rejectionReason as rejecti13_2_, check0_.observation as observa14_2_, check0_.accountNumber as account15_2_, check0_.subsidiary_uid as subsidiary16_2_, check0_.checktype_uid as checktype17_2_, check0_.applicationType as applica18_2_, check0_.appliedDate as applied19_2_, check0_.checkBookNumber as checkBo20_2_, check0_.type_id as type2_ from CHECKS check0_, SUBSIDIARY subsidiary1_, BANK bank2_ where (check0_.number='7777' and check0_.serie='12A' and bank2_.code='1' and check0_.subsidiary_uid=subsidiary1_.uid and subsidiary1_.bank_uid=bank2_.uid)
Hibernate: select checktype0_.uid as uid0_, checktype0_.expireDate as expireDate3_0_, checktype0_.type_id as type2_0_ from CHECK_TYPE checktype0_ where checktype0_.uid=?
I will that the information will be sufficient.
regards
epsino