NPersistence Reference Guide

Overload List

NameDescription
Find<(Of <<'(T>)>>)(Type, Object)
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.
Find<(Of <<'(T>)>>)(Type, Object, LockModeType)
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 the persistence context, it is returned from there, and the effect of this method is the same as if the lock method had been called on the entity. If the 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 OptimisticLockException will be thrown. If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
  • the PessimisticLockException will be thrown if the database locking failure causes transaction-level rollback
  • the LockTimeoutException will be thrown if the database locking failure causes only statement-level rollback
Find<(Of <<'(T>)>>)(Type, Object, Dictionary<(Of <<'(String, Object>)>>))
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 context, it is returned from there. If a vendor-specific property or hint is not recognized, it is silently ignored.
Find<(Of <<'(T>)>>)(Type, Object, LockModeType, Dictionary<(Of <<'(String, Object>)>>))
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 to the specified lock type. If the entity instance is contained in the persistence context, it is returned from there. If the 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 OptimisticLockException will be thrown. If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
  • the PessimisticLockException will be thrown if the database locking failure causes transaction-level rollback
  • the LockTimeoutException will be thrown if the database locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored. Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.

See Also