public class DbDefaultValue extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FALSE
The key for FALSE.
|
static String |
NOW
The key for the NOW / current timestamp.
|
static String |
NULL
The 'null' literal.
|
static String |
TRUE
The key for TRUE.
|
Constructor and Description |
---|
DbDefaultValue() |
Modifier and Type | Method and Description |
---|---|
String |
convert(String dbDefaultLiteral)
Convert the DB default literal to platform specific type or function.
|
void |
put(String dbLiteral,
String dbTranslated)
Add an translation entry.
|
void |
setFalse(String dbFalseLiteral)
Set the DB false literal.
|
void |
setNow(String dbFunction)
Set the DB now function.
|
void |
setTrue(String dbTrueLiteral)
Set the DB true literal.
|
static String |
toSqlLiteral(String defaultValue,
Class<?> propertyType,
int sqlType)
This method checks & convert the
DbDefault.value() to a valid SQL literal. |
public static final String FALSE
public static final String TRUE
public static final String NOW
public static final String NULL
public DbDefaultValue()
public String convert(String dbDefaultLiteral)
This is intended for the DB column default clause in DDL.
public static String toSqlLiteral(String defaultValue, Class<?> propertyType, int sqlType)
DbDefault.value()
to a valid SQL literal.
This is mainly to quote string literals and verify integer/dates for correctness.
Note: There are some special cases:
@DbDefault("User's default")
on a String propery
returns: default 'User''s default'
@DbDefault("null")
will return this: default null
@DbDefault("'null'")
which gives you the default 'null'
statement.@DbDefault("$RAW:N'SANDNES'")
will lead to
a default N'SANDNES'
in DDL. Note that this is platform specific!Copyright © 2018. All rights reserved.