Hello,
I have a class that I want to be in a one-to-one object with multiple different objects. Unfortunately if I understand the hibernate <one-to-one> mapping correctly it works by selecting objects where the identifiers of each object are equal. In my case I need to create a one-to-one relationship where the foriegn key is not the same as the identifier.
Second problem:
When testing the foriegn generator I came across the following stack trace.
Code:
Exception in thread "main" net.sf.hibernate.AssertionFailure: null id
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:664)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214)
at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.java:81)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:238)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:306)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:708)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214)
at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.java:81)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:238)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:272)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:306)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:754)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214)
at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.java:81)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:238)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:272)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:306)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:754)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214)
at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.java:81)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:238)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:306)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:708)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214)
at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.java:81)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:238)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:306)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:708)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214)
at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.java:81)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:238)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:306)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:708)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620)
at com.atwoodsoft.tests.client.DomainModelTest.saveStructure(DomainModelTest.java:504)
at com.atwoodsoft.tests.client.DomainModelTest.main(DomainModelTest.java:708)
I suspect that what is happening is that the foreign generator does not work when the other object participating in the <one-to-one> relationship uses the native generator.
For now I suppose I will have to work around these problems by using <many-to-one> mappings instead of <one-to-one> mappings. Unfortunately this is less than optimal because my design really calls for <one-to-one> relationships.
As always any advice would be appreciated.
John Atwood