[
http://opensource.atlassian.com/projects/hibernate/browse/EJB-221?page=co...
]
Emmanuel Bernard commented on EJB-221:
--------------------------------------
The TransientObjectException is a bug,
But the SELECT triggered is expected. Hibernate does not know that getId() is actually
accessing only the id field, hence does not requires a SELECT. getId() is just a regular
method
TransientObjectException with FetchType.LAZY on @ManyToOne and field
access on target entity
--------------------------------------------------------------------------------------------
Key: EJB-221
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-221
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Reporter: Christian Bauer
Priority: Blocker
Fix For: 3.2.0.cr1, 3.2.0.cr2
Attachments: fetchtest.jar
Latest SVN of everything:
em = factory.createEntityManager();
em.getTransaction().begin();
Soldier2 soldier = em.find(Soldier2.class, mickey.getId());
System.out.println("### TRYING TO ACCESS PROXY ID...");
// This triggers a SELECT, it shouldn't
System.out.println("### PROXY ID : " + soldier.getTroop().getId());
// This throws a TransientObjectException
em.flush();
The @ManyToOne troop in Soldier2.java has only FetchType.LAZY, the CascadeType.PERSIST is
removed.
I expect the problem to be in CascadingAction PERSIST_ON_FLUSH.noCascade() somewhere,
apparently the proxy has no Id anymore during flush-time and is considered transient (how
can a proxy be transient?).
The problems appear as soon as I move the annotations from getters to fields in
Troop2.java.
The attached tests are for HEM.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira