Annotation Type MappedUDT


  • @Target(TYPE)
    @Retention(CLASS)
    @Documented
    public @interface MappedUDT
    Annotation on a PL/Java class that will either map an existing PostgreSQL type (provided its internal storage form is well understood), or create and map a new PostgreSQL composite type (a/k/a "structured type" in the standards).

    A class marked with this annotation must implement SQLData, and will use the methods of that interface to map between its own state and the PostgreSQL internal form. If this annotation includes a structure, SQL will be emitted to create a new composite type with that structure in the schema named here (or at the head of the search_path if unspecified), and with the name given here (or else the simple name of the class being annotated), and then to use the sqlj.add_type_mapping function to associate that type with the annotated class.

    If no structure is given, no new type will be created, and sqlj.add_type_mapping will simply be called to map some existing PostgreSQL type (known by name if specified or the simple name of the class being annotated, and found in schema if specified, or by following the search path) to the annotated class.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String comment
      A comment to be associated with the type.
      String implementor
      The <implementor name> to be used around SQL code generated for this type.
      String name
      Name of the type in SQL, if it is not to be the simple name of the class.
      String[] provides
      One or more arbitrary labels that will be considered 'provided' by the object carrying this annotation.
      String[] requires
      One or more arbitrary labels that will be considered 'required' by the object carrying this annotation.
      String schema
      Schema in which the type is declared.
      String[] structure
      Structure of the new composite ("structured") type to create, as strings, one per attribute, for example {"x float8", "y float8"}.
    • Element Detail

      • name

        String name
        Name of the type in SQL, if it is not to be the simple name of the class. By default, the class name will be used, subject to PostgreSQL's normal case-folding and case-insensitive matching.
        Default:
        ""
      • schema

        String schema
        Schema in which the type is declared. If not given, the names will not be schema qualified.
        Default:
        ""
      • provides

        String[] provides
        One or more arbitrary labels that will be considered 'provided' by the object carrying this annotation. The deployment descriptor will be generated in such an order that other objects that 'require' labels 'provided' by this come later in the output for install actions, and earlier for remove actions.
        Default:
        {}
      • requires

        String[] requires
        One or more arbitrary labels that will be considered 'required' by the object carrying this annotation. The deployment descriptor will be generated in such an order that other objects that 'provide' labels 'required' by this come earlier in the output for install actions, and later for remove actions.
        Default:
        {}
      • implementor

        String implementor
        The <implementor name> to be used around SQL code generated for this type. Defaults to PostgreSQL. Set explicitly to "" to emit code not wrapped in an <implementor block>.
        Default:
        ""
      • structure

        String[] structure
        Structure of the new composite ("structured") type to create, as strings, one per attribute, for example {"x float8", "y float8"}. Collation syntax could be included if needed as well; the strings are simply dumped, with commas between, into the CREATE TYPE command.

        An empty list {} is allowed, and will create a composite type with no attributes at all; PostgreSQL expressly allows this for some reason, and you can still tell whether you have one of those or null, so it could be used as a strange sort of boolean.

        If no structure is given at all, no type is created, and this annotation simply maps the class being annotated to some existing PostgreSQL type.

        Default:
        {}
      • comment

        String comment
        A comment to be associated with the type. If left to default, and the Java class has a doc comment, its first sentence will be used. If an empty string is explicitly given, no comment will be set.
        Default:
        ""