Annotation Type JdbcStatement


@Target({TYPE,METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER}) @Retention(RUNTIME) @Documented @Constraint(validatedBy=io.xlate.validation.internal.constraintvalidators.JdbcStatementValidator.class) @Repeatable(List.class) public @interface JdbcStatement
Constraint to execute a read-only JDBC statement (i.e., a query). By default, if the query returns at least one result row, the validation is considered to be successful. Statements are executed using the default DataSource, java:comp/DefaultDataSource.
Author:
Michael Edgar
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Defines several JdbcStatement annotations on the same element.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The JDBC statement to execute to determine the validity of the constraint.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The JNDI lookup name of the resource to be used to obtain a Connection.
    Class<?>[]
     
     
    Name of the node to be identified in a ConstraintViolation should validation fail.
    The list of EL expressions used to derive parameters values to be bound to parameter markers (i.e.
    Class<? extends jakarta.validation.Payload>[]
     
    An EL expression used to determine if the expression given by value() should be checked.
  • Element Details

    • value

      String value
      The JDBC statement to execute to determine the validity of the constraint. The statement must be a valid SQL text that may be used with Connection.prepareStatement(String) and (subsequently) PreparedStatement.executeQuery(). The validation is considered successful when the result of the statement execution returns at least one row from the database.
      Returns:
      the JDBC query to evaluate to determine the validity of the constraint
    • message

      String message
      Default:
      "statement `{value}` did not return any results"
    • groups

      Class<?>[] groups
      Default:
      {}
    • payload

      Class<? extends jakarta.validation.Payload>[] payload
      Default:
      {}
    • parameters

      String[] parameters
      The list of EL expressions used to derive parameters values to be bound to parameter markers (i.e. ?) in the SQL statement given by value(). The annotated target is available as 'self' in expressions. The parameters must be given in the same order that they are to be bound to the parameter marker in the SQL statement.
      Returns:
      the list of EL expressions used to derive parameters values
      Default:
      {}
    • when

      String when
      An EL expression used to determine if the expression given by value() should be checked. This expression is available to short-circuit the constraint validation of this Expression in scenarios when it should not apply, e.g. a value is null and the constraint only applies to non-null values.
      Returns:
      the expression to evaluate to determine whether the constraint should be checked
      Default:
      ""
    • dataSourceLookup

      String dataSourceLookup
      The JNDI lookup name of the resource to be used to obtain a Connection. It can link to any compatible DataSource using the global JNDI names.
      Returns:
      the JNDI lookup name of the resource to be used to obtain a Connection
      Default:
      ""
    • node

      String node
      Name of the node to be identified in a ConstraintViolation should validation fail.
      Returns:
      the name of the node to be identified in a ConstraintViolation should validation fail.
      Default:
      ""