Hibernate version: 3.1.3
Hello,
I have a class A with a many-to-one reference to class B.
An instance b of Class B is retrieved through a normal session.
Now I create a new instance a of A, call a.setB(b), then call StatelessSession.insert(a);
The result is an UnsupportedOperationException:
java.lang.UnsupportedOperationException
at org.hibernate.impl.StatelessSessionImpl.getTimestamp(StatelessSessionImpl.java:268)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3016)
at ....
If I retrieve the instance of class B using the same StatelessSession instead, I get another stack trace:
an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:100)
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.loadEntity(Loader.java:1785)
Note: I am not expecting any cascading here, I would just expect that the StatelessSession operation would fetch the id-value of the related class and put that id-value into the insert statement for class A.
Is it really impossible to use StatelessSession.insert() for a class that has many-to-one property to some other class?
|