I\'m a bit confused. The question is in title, and here\'s why I\'m asking.
I have JSF + JPA web-application running on a single VM.
And an JPA class has @Transient<
If you invoke find(..)
within the same session (that is, within the same entitymanager lifetime), then the same object reference will be returned. The documentation of find() specifies this:
If the entity instance is contained in the persistence context, it is returned from there.
In other words, the EntityManager
holds a collection (map most likely) of entities. When you call find
it checks that collection. If the entity is not found there, a query to the database is made. The returned entity is put into the map, so subsequent calls will find it there.
But note again that this is only for the span of one session. This is usually the same as one http request (in the web app context)