Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents
 Search
 PDFComments
Comments


@ExistenceChecking

Use @ExistenceChecking to specify how EclipseLink should check to determine if an entity is new or exists.

On merge() operations, use @ExistenceChecking to specify if EclipseLink uses only the cache to determine if an object exists, or if the object should be read (from the database or cache). By default the object will be read from the database.


Annotation Elements

Table 2-20 describes this annotation's elements.

Table 2-20 @ExistenceChecking Annotation Elements

Annotation Element Description Default

ExistenceType

(Optional) Set the existence checking type:

  • ASSUME_EXISTENCE

  • ASSUME_NON_EXISTENCE

  • CHECK_CHACHE

  • CHECK_DATABASE

CHECK_CACHE



Usage

You can specify @ExistenceChecking on an Entity or MappedSuperclass.

EclipseLink supports the following existence checking types:


Examples

Example 2-41 shows how to use this annotation.

Example 2-41 Using @ExistenceChecking Annotation

@Entity
@Cache(type=CacheType.HARD_WEAK,  expiryTimeOfDay=@TimeOfDay(hour=1))
@ExistenceChecking(ExistenceType.CHECK_DATABASE)
public  class  Employee  implements  Serializable  { 
...
}


See Also

For more information, see: