Package io.ebean.config.dbplatform
Class DbDefaultValue
java.lang.Object
io.ebean.config.dbplatform.DbDefaultValue
public class DbDefaultValue extends Object
DB Column default values mapping to database platform specific literals.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DbDefaultValue()
-
Method Summary
Modifier and Type Method 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 and converts theDbDefault.value()
to a valid SQL literal.
-
Field Details
-
FALSE
The key for FALSE.- See Also:
- Constant Field Values
-
TRUE
The key for TRUE.- See Also:
- Constant Field Values
-
NOW
The key for the NOW / current timestamp.- See Also:
- Constant Field Values
-
NULL
The 'null' literal.- See Also:
- Constant Field Values
-
-
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:
-