Top Description Methods
jakarta.data.repository

public @Interface Save

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:METHOD
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target

Lifecycle annotation for repository methods which conditionally perform insert or update operations.

The Save annotation indicates that the annotated repository method accepts one or more entities and, for each entity, either adds its state to the database, or updates state already held in the database.

A Save method accepts an instance or instances of an entity class. The method must have exactly one parameter whose type is either:

The annotated method must either be declared void, or have a return type that is the same as the type of its parameter.

All Jakarta Data providers are required to accept a Save method which conforms to this signature. Application of the Save annotation to a method with any other signature is not portable between Jakarta Data providers.

For example, consider an interface representing a garage:

@Repository
interface Garage {
    @Save
    Car park(Car car);
}

The operation performed by the annotated method depends on whether the database already holds an entity with the unique identifier of an entity passed as an argument:

Annotations such as @Find, @Query, @Insert, @Update, @Delete, and @Save are mutually-exclusive. A given method of a repository interface may have at most one @Find annotation, lifecycle annotation, or query annotation.

See Also
Insert, Update

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString