Reputation: 8705
Question:
PersistenceUtil.isLoaded is evaluated by looking at which EntityManager or is it L2 Cache? After all Entities are loaded by only one of these.
PersistenceUtil.isLoaded method definition says:
"Determine the load state of an entity. This method can be used to determine the load state of an entity passed as a reference." But there is no mention of loaded where?
Upvotes: 1
Views: 1017
Reputation: 22672
I've checked the source code with the implementation of this interface. Looks like isLoaded
is going over all defined persistent providers and checks if entity is attached to any of them.
As a result you can't know to which EntityManager your entity is bound.
Upvotes: 1
Reputation: 16142
Entities in JPA are attached to an entity manager, and there's plumbing to help you with that - see f.e. clear()
, contains()
, merge()
in EntityManager
alone.
Usually entities are attached to the EntityManager
that created them. It's not a good idea to mix entities from different EntityManager
s.
Upvotes: 1