Hitachi

uCosminexus Application Server Compatibility Guide


9.4.4 Obtaining the entities from the database

By invoking the find method or getReference method of EntityManager, you can obtain the entities corresponding to the primary key specified in the argument, from the database.

The entities returned by the find method or getReference method of EntityManager use the persistence context of the transaction scope. Therefore, when the method is invoked within the transaction, the state changes to managed. Also, if the find method or getReference method is invoked outside the transaction, the state changes to detached.

The following table describes the state of entities obtained with the find operation or getReference operation.

Table 9‒10: State of entities obtained with the find operation or getReference operation

Persistence context

State of the obtained entity

Persistence context of the transaction scope (outside the transaction)

detached

Persistence context of the transaction scope (within the transaction)

managed

Extended persistence context (outside the transaction)

managed

Extended persistence context (within the transaction)

managed

Note that for Cosminexus JPA Provider, the following points differ from the JPA specifications in the find operation or getReference operation. Note that apart from these differences, there are no other functionality differences with the JPA specifications.