 84 | whose primary key is 1:
Employee employee = em.find(Employee.class, 1);
Casting of the retrieved object to Employee is not required because find is defined as returning an instance of the same class ... is returned. A similar method, getReference, can be considered the lazy version of find:
Employee |
 79 | one atomic operation. For example, the find method has a form that accepts a lock mode:
Employee employee = em.find(
Employee.class, 1, LockModeType.PESSIMISTIC_WRITE); Similarly, the refresh ... ", 2000);
Employee employee = em.find(
Employee.class, 1, LockModeType.PESSIMISTIC_WRITE |
 69 | Method javax.persistence.EntityManager T find( Class entityClass, Object primaryKey ) Find by primary key. Search for an entity of the specified class and primary key. If the entity instance is contained in the persistence context, it is returned from there. Parameters: entityClass - entity |
 69 | Method javax.persistence.EntityManager T find( Class entityClass, Object primaryKey, LockModeType lockMode ) Find by primary key and lock. Search for an entity of the specified class and primary key and lock it with respect to the specified lock type. If the entity instance is contained in |
 69 | Method javax.persistence.EntityManager T find( Class entityClass, Object primaryKey, LockModeType lockMode, Map properties ) Find by primary key and lock, using the specified properties. Search for an entity of the specified class and primary key and lock it with respect |
 69 | Method javax.persistence.EntityManager T find( Class entityClass, Object primaryKey, LockModeType lockMode, Map properties ) Find by primary key and lock, using the specified properties. Search for an entity of the specified class and primary key and lock it with respect |
 69 | Method javax.persistence.EntityManager T find( Class entityClass, Object primaryKey, Map properties ) Find by primary key, using the specified properties. Search for an entity of the specified class and primary key. If the entity instance is contained in the persistence |
 69 | Methodjavax.persistence.EntityManager T find( Class entityClass, Object primaryKey, LockModeType lockMode, Map properties ) Find by primary key and lock, using the specified properties. Search for an entity of the specified class and primary key and lock it with respect |
 62 | Explains how to use JPA for CRUD database operations (persist, retrieve, update, remove). |
 26 | , why? Result:
===========
find time @ 24.125000
getSons time @ 0.000000
1 : type:Nodes, sons:2
child : 2
child : 3
Iterator time @ 0.000000
find time @ 0.000000
getSons time @ 0.000000
2 : type:Nodes, sons:2
child : 4
child : 5
Iterator time @ 0.000000
find time @ 0.000000
getSons |