java.lang.Object
io.ebean.config.dbplatform.DbDefaultValue
DB Column default values mapping to database platform specific literals.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionConvert the DB default literal to platform specific type or function.void
Add an translation entry.void
Set the DB false literal.void
Set the DB now function.void
Set the DB true literal.static String
toSqlLiteral
(String defaultValue, Class<?> propertyType, int sqlType) This method checks and converts theDbDefault.value()
to a valid SQL literal.
-
Field Details
-
FALSE
The key for FALSE.- See Also:
-
TRUE
The key for TRUE.- See Also:
-
NOW
The key for the NOW / current timestamp.- See Also:
-
NULL
The 'null' literal.- See Also:
-
map
-
-
Constructor Details
-
DbDefaultValue
public DbDefaultValue()
-
-
Method Details
-
setNow
Set the DB now function. -
setFalse
Set the DB false literal. -
setTrue
Set the DB true literal. -
put
Add an translation entry. -
convert
Convert the DB default literal to platform specific type or function.This is intended for the DB column default clause in DDL.
-
toSqlLiteral
This method checks and converts theDbDefault.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:
- Normal Quoting:
@DbDefault("User's default")
on a String propery returns:default 'User''s default'
(the same on an integer property will throw a NumberFormatException) - Special case null:
@DbDefault("null")
will return this:default null
If you need really the String "null", you have to specify@DbDefault("'null'")
which gives you thedefault 'null'
statement. - Any statement, that begins and ends with single quote will not be checked or get quoted again.
- A statement that begins with "$RAW:", e.g
@DbDefault("$RAW:N'SANDNES'")
will lead to adefault N'SANDNES'
in DDL. Note that this is platform specific!
- Normal Quoting:
-