[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-4923) EnitityManager returning lazy proxy
Steve Ebersole (JIRA)
noreply at atlassian.com
Tue Feb 16 16:22:50 EST 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4923?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Ebersole closed HHH-4923.
-------------------------------
Resolution: Rejected
Yep, the only concern would be if the proxy were not initialized after the find() call. But returning a (initialized) proxy is completely expected if the proxy were already associated with the persistence context
> EnitityManager returning lazy proxy
> -----------------------------------
>
> Key: HHH-4923
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4923
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.3.2
> Environment: JBoss - MySQL 5.1 - JDK6
> Reporter: Billy Bob
>
> Depending on the order I read entities, sometimes an em.find() returns a javassist proxy. I have the following simplified entity mapping:
> class A {
> @Id
> @GeneratedValue(strategy=GenerationType.IDENTITY)
> private int id;
> }
> class B extends A {
> }
> class C extends A {
> @ManyToOne(fetch=FetchType.LAZY)
> @JoinColumn(nullable=false)
> private A ref;
> }
> For both scenarios, I have an entity of type B stored with id 20 and an entity of type C stored with id 30 with a reference to the first object with id 20.
> Scenario - 1:
> em.find(A.class, 30); // Returns type C, lazy reference of B is loaded into session
> em.find(A.class, 20); // Error: Returns javassist proxy instead of type B
> Scenario - 2:
> em.find(A.class, 20); // Returns type B, since not loaded by C lazy reference
> em.find(A.class, 30); // Returns type C
> Should a call to EntityManager.find() ever return a lazy proxy?
--
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list