I am using hibernate 3.1.3 with j2sdk1.4.2 with a Sybase12.5 database.
My problem is this - I have 2 classes Funding and Tracking. There is a one-to-one relationship from Funding to Tracking. If I do not define the relationship in Hibernate and manage the relationship "manually" there is no problem reading, writing, and deleting both objects. But if I use the following hbm.xml files to tell Hibernate about the relationship, I get the following exception when I retrieve a Funding object and try to access it's associated Tracking object.
The way I map the Funding object to the Tracking object in my hbm.xml file is:
Code:
<one-to-one name="tracking" class="ownit.value.Tracking" constrained="true"/>
Is this sufficient?
10:35:32:527|DEBUG|org.hibernate.util.JDBCExceptionReporter|could not load an entity: [ownit.value.Tracking#component[loanNumber,settleDate]{loanNumber=1001858421, settleDate=2006-01-03 00:00:00}] [select tracking0_.loanNumber as loanNumber20_0_, tracking0_.settleDate as settleDate20_0_, tracking0_.yield as yield20_0_, tracking0_.gainAAdj as gainAAdj20_0_, tracking0_.gainBAdj as gainBAdj20_0_, tracking0_.gainPerLoan as gainPerL6_20_0_, tracking0_.interestDue as interest7_20_0_, tracking0_.interestPending as interest8_20_0_, tracking0_.priceReduction as priceRed9_20_0_, tracking0_.targetRevenue as targetR10_20_0_, tracking0_.trueUpAmount as trueUpA11_20_0_ from Tracking tracking0_ where tracking0_.loanNumber=? and tracking0_.settleDate=?]
java.sql.SQLException: JZ0NC: wasNull called without a preceding call to get a column.
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:498)
at com.sybase.jdbc2.jdbc.SybResultSet.wasNull(SybResultSet.java:194)
at aot.util.DecimalType.nullSafeGet(DecimalType.java:51)
at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:104)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1899)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1300)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:82)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:820)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:62)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at ownit.value.Tracking$$EnhancerByCGLIB$$4bf953c1.getInterestDue(<generated>)
at aot.util.TestHibernate.doQueryFunding(TestHibernate.java:237)
at aot.util.TestHibernate.testStoreDomainObjects(TestHibernate.java:882)
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:324)
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:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Code: