Annotation Type SQLType


  • @Documented
    @Target(PARAMETER)
    @Retention(CLASS)
    public @interface SQLType
    Optionally annotates a Java method parameter, to supply an explicit SQL type for use in the SQL function declaration in place of the automatically mapped type, and/or to supply an SQL default value. This annotation cannot be used to supply the SQL declaration's return type, but @Function(type=...) can.
    Author:
    Thomas Hallgren - pre-Java6 version, Chapman Flack (Purdue Mathematics) - updated to Java6, added SQLType
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String[] defaultValue
      Default value for the parameter.
      String name
      SQL name for the parameter, to allow calling the function using named parameter notation, in preference to the parameter's Java name.
      boolean optional
      What optional=true means is just what defaultValue=null would mean, if Java permitted null values in annotations.
      String value
      The SQL type name to use for the annotated parameter in preference to any found in the default mappings.
    • Element Detail

      • value

        String value
        The SQL type name to use for the annotated parameter in preference to any found in the default mappings.
        Default:
        ""
      • defaultValue

        String[] defaultValue
        Default value for the parameter. Parameters of row or array type can have defaults too, so this element accepts an array. For a scalar type, just supply one value. Values given here go into the descriptor file as properly-escaped string literals explicitly cast to the parameter type, which covers the typical case of defaults that are simple literals or can be computed as Java String-typed constant expressions (e.g. ""+Math.PI) and ensures the parsability of the descriptor file.

        For a row type of unknown structure (PostgreSQL type RECORD), the only default that can be specified is {}, which can be useful for functions that use a RECORD parameter to accept an arbitrary sequence of named, typed parameters from the caller. For a named row type (not RECORD), an array of nonzero length will be accepted. It needs to match the number and order of components of the row type (which cannot be checked at compile time, but will cause the deployment descriptor code to fail at jar install time if it does not).

        A Java annotation value cannot be null. If null is what the default value should be, use optional=true.

        Default:
        {}
      • optional

        boolean optional
        What optional=true means is just what defaultValue=null would mean, if Java permitted null values in annotations.

        There is no difference between optional=false and simply having no optional or defaultValue element at all.

        Only one of optional or defaultValue may be present in one annotation.

        If optional=true, the function must not be annotated with onNullInput=RETURNS_NULL.

        Default:
        false
      • name

        String name
        SQL name for the parameter, to allow calling the function using named parameter notation, in preference to the parameter's Java name. By default, the SQL name is taken from the Java name, but in some cases the SQL name expected by callers may be a reserved word in Java, or the Java name may be reserved in SQL. The name specified here can simply be different, or it can be given in quoted-identifier form to work around the reservedness in SQL of the unquoted name. Callers, in that case, have to quote the name also, but that may be acceptable for clarity's sake if there is a particular name that is used in a standard or is otherwise the most natural choice.
        Default:
        ""