What does PersistenceUtil.isLoaded means?

允我心安 提交于 2019-12-13 00:12:25

问题


Could somebody explain what does PersistenceUtil.isLoaded returns in the context of JPA and hibernate. My impression was that it identifies if the value is loaded and can be accessed without database access. But recently I came upon a case that PesistenceUtil.isLoaded returns true, while the object is an instance of HibernateProxy, and any access to it throws a LIE. I would appreciate any comments.


回答1:


Method isLoaded in PersistenceUtil checks is entity loaded. Entity being loaded means that all eager attributes are loaded from database or assigned by application. In JPA 2.0 specification this is told with following words:

An entity is considered to be loaded if all attributes with FetchType.EAGER—whether explictly specified or by default—(including relationship and other collection-valued attributes) have been loaded from the database or assigned by the application. Attributes with FetchType.LAZY may or may not have been loaded.

For detailed explanation, please refer to JPA 2.0 specification, 3.2.9 Load State.



来源:https://stackoverflow.com/questions/10437552/what-does-persistenceutil-isloaded-means

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!