Annotation Interface NamedStatement


@Repeatable(NamedStatements.class) @Target({TYPE,PACKAGE,MODULE}) @Retention(RUNTIME) public @interface NamedStatement
Declares a named statement written in the Jakarta Persistence Query Language. Statement names are scoped to the persistence unit. The statement must be an UPDATE or DELETE query.

This annotation may be applied to any class or interface belonging to the persistence unit.

@NamedStatement(name = "deleteNamedCustomers",
            statement = "delete from Customer c where c.name like :custName")
@Entity
class Customer { ... }

A named statement may be executed by calling EntityHandler.createNamedStatement(String).

em.createNamedStatement("deleteNamedCustomers")
            .setParameter("custName", "Smith")
            .execute();
Since:
4.0
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    (Required) The name used to identify the query in calls to EntityHandler.createNamedStatement(String).
    (Required) The statement string in the Jakarta Persistence query language.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    (Optional) Query properties and hints.