Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add EntityManager.findMultiple() #659

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions api/src/main/java/jakarta/persistence/EntityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

// Contributors:
// Gavin King - 4.0
// Gavin King - 3.2
// Linda DeMichiel - 2.1
// Linda DeMichiel - 2.0
Expand Down Expand Up @@ -450,6 +451,44 @@ <T> T find(Class<T> entityClass, Object primaryKey,
<T> T find(Class<T> entityClass, Object primaryKey,
FindOption... options);

/**
* Find the instances of the given entity class with the primary keys
* in the given list, using the given {@linkplain FindOption options}.
* The position of an instance in the list matches the position of
* its primary key in the list, and the list contains a null value if
* there is no persistent instance matching a given primary key.
* If an entity instance is contained in the persistence context,
* it is returned from there.
* <p>If an entity is found within the persistence context and
* the lock mode type is pessimistic and the entity has a version
* attribute, the persistence provider must perform optimistic
* version checks when obtaining the database lock. If these checks
* fail, the {@code OptimisticLockException} is thrown.
* <p>If the lock mode type is pessimistic and the entity instance
* is found but cannot be locked:
* <ul>
* <li>the {@code PessimisticLockException} is thrown if the
* database locking failure causes transaction-level
* rollback
* <li>the {@code LockTimeoutException} is thrown if the database
* locking failure causes only statement-level rollback
* </ul>
* <p>If a vendor-specific {@linkplain FindOption option} is not
* recognized, it is silently ignored.
* <p>Portable applications should not rely on the standard
* {@linkplain Timeout timeout option}. Depending on the database
* in use and the locking mechanisms used by the provider, this
* option may or may not be observed.
* @param entityClass the entity type
* @param primaryKeys ordered list of primary keys
* @param options standard and vendor-specific options
* @return an ordered list of persistent instances, with null elements
* representing missing entities
* @since 4.0
*/
<T> List<T> findMultiple(Class<T> entityClass, List<Object> primaryKeys,
FindOption... options);

/**
* Find an instance of the root entity of the given {@link EntityGraph}
* by primary key, using the specified {@linkplain FindOption options},
Expand Down