Beginner |
|
Joined: Fri Oct 24, 2003 10:45 am Posts: 22
|
Hi,
I would appreciate any advice regarding the foloowing issue.
I have two classes with the following mappings:
<class name="com.usaa.bank.clo.bom.financialstatement.FinancialItem" table="financial_item" lazy="false">
<id name="id" type="long" column="id">
<generator class="sequence">
<param name="sequence">financial_item_seq</param>
</generator>
</id>
<any name="product" access="field" meta-type="class" id-type="long" cascade="all">
<column name="product_class"/>
<column name="product_id"/>
</any>
</class>
<class name="com.usaa.bank.clo.bom.product.Product" table="product" lazy="true">
<id name="id" type="long" column="id">
<generator class="sequence">
<param name="sequence">product_seq</param>
</generator>
</id>
<one-to-one name="financialItem" class="com.usaa.bank.clo.bom.financialstatement.FinancialItem" outer-join="false" constrained="false" cascade="all" property-ref="product"/>
<joined-subclass>
...
</joined-subclass>
<joined-subclass>
...
</joined-subclass>
<joined-subclass>
...
</joined-subclass>
<joined-subclass>
...
</joined-subclass>
</class>
In FinancialItem class I had to use <any> mapping to avoid polymorphism problems when using lazy loading proxy (chapter 14.2 of hibernate doc)
But when I try to persist an instance of FinancialItem I am getting the following exception
net.sf.hibernate.MappingException: No persister for: java.lang.Long
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:344)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2656)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2663)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2725)
at net.sf.hibernate.type.ObjectType.nullSafeSet(ObjectType.java:139)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:674)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:713)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:831)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:851)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
at net.sf.hibernate.loader.EntityLoader.loadByUniqueKey(EntityLoader.java:53)
at net.sf.hibernate.persister.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1104)
at net.sf.hibernate.impl.SessionImpl.loadByUniqueKey(SessionImpl.java:3806)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:218)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2169)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:831)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:851)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49)
at net.sf.hibernate.persister.NormalizedEntityPersister.load(NormalizedEntityPersister.java:405)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2081)
at net.sf.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1899)
at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:53)
at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:60)
at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:164)
at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108)
at com.usaa.bank.clo.bom.product.LoanProduct$$EnhancerByCGLIB$$39359c34.getRealClass(<generated>)
at com.usaa.bank.clo.bom.financialstatement.FinancialItem.getProduct(FinancialItem.java:630)
at com.usaa.bank.clo.bom.financialstatement.FinancialItemPersistenceTest.update(FinancialItemPersistenceTest.java:150)
at com.usaa.bank.clo.persistence.mgmt.PersistenceTest.testPersistence(PersistenceTest.java:185)
at java.lang.reflect.Method.invoke(Native Method)
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:329)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:218)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:151)
That does not happen if I don't use back reference (<one-to-one>) in Product class.
It looks like it is impossible to use <one-to-one> with property-ref when other side of bidirectional relationship is mapped with <any>
Any ideas?
thanks,
Andrey
|
|