Package io.ran

Annotation Interface DbName


@Retention(RUNTIME) @Target({TYPE,FIELD}) public @interface DbName
@DbName is used to specify the name of a table or column in the database.

This is especially useful when the name of the table or column is a reserved word in the database, or when the data model is being generated from an existing database.

Example:


 @DbName("users")
 public class User {
    @DbName("user_id")
    public Long id;
    @DbName("user_name")
    public String name;
 }
 
 

This will use a table named "users" with columns "user_id" and "user_name", instead of "user" with columns "id" and "name".

When DbName is not specified a default pattern is used to convert the name of the field to the name of the column, and the name of the class to the name of the table. This works by converting all names to snake_case (from camelCase or PascalCase). The final pattern is controlled by the ORM implementation, so it may be different for different databases.

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the table or column in the database.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether to treat the value passed as the literal target name of the table or column, or a Token to be converted to the name of the table or column.
  • Element Details

    • value

      String value
      The name of the table or column in the database.
      Returns:
      the name of the table or column in the database, alphanumerics and underscores only
    • literal

      boolean literal
      Whether to treat the value passed as the literal target name of the table or column, or a Token to be converted to the name of the table or column.
      Returns:
      true if the value is a literal name, false if it is a Token
      Default:
      true