Annotation Interface NamedNativeStatement


@Repeatable(NamedNativeStatements.class) @Target(TYPE) @Retention(RUNTIME) public @interface NamedNativeStatement
Declares a named statement written in native SQL. Statement names are scoped to the persistence unit. The SQL statement must return a row count.

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

@NamedNativeStatement(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 written in native SQL.
  • Optional Element Summary

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