本文整理汇总了Java中liquibase.statement.DatabaseFunction类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseFunction类的具体用法?Java DatabaseFunction怎么用?Java DatabaseFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseFunction类属于liquibase.statement包,在下文中一共展示了DatabaseFunction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convertObjectToString
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
@Override
public String convertObjectToString(Object value, Database database) {
if (value == null) {
return null;
} else if (value.toString().equalsIgnoreCase("null")) {
return "null";
} else if (value instanceof DatabaseFunction) {
return ((DatabaseFunction) value).getValue();
} else if (value.toString().equals("CURRENT_TIMESTAMP()")) {
return database.getCurrentDateTimeFunction();
} else if (value instanceof java.sql.Timestamp) {
return database.getDateLiteral(((java.sql.Timestamp) value));
} else if (value instanceof java.sql.Date) {
return database.getDateLiteral(((java.sql.Date) value));
} else if (value instanceof java.sql.Time) {
return database.getDateLiteral(((java.sql.Time) value));
} else if (value instanceof java.util.Date) {
return database.getDateLiteral(((java.util.Date) value));
} else {
return "'"+((String) value).replaceAll("'","''")+"'";
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:23,代码来源:DateType.java
示例2: convertObjectToString
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
@Override
public String convertObjectToString(Object value, Database database) {
if (value == null) {
return null;
} else if (value.toString().equalsIgnoreCase("null")) {
return "null";
} else if (value instanceof DatabaseFunction) {
return ((DatabaseFunction) value).getValue();
} else if (value.toString().equals("CURRENT_TIMESTAMP()")) {
return database.getCurrentDateTimeFunction();
} else if (value instanceof java.sql.Time) {
return database.getTimeLiteral(((java.sql.Time) value));
} else {
return "'"+((String) value).replaceAll("'","''")+"'";
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:17,代码来源:TimeType.java
示例3: convertObjectToString
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
@Override
public String convertObjectToString(Object value, Database database) {
if (value == null) {
return null;
} else if (value.toString().equalsIgnoreCase("null")) {
return "null";
} else if (value.toString().equals("CURRENT_TIMESTAMP()")) {
return database.getCurrentDateTimeFunction();
} else if (value instanceof DatabaseFunction) {
return ((DatabaseFunction) value).getValue();
} else if (database.getDatabaseFunctions().contains(new DatabaseFunction(value.toString()))) {
return value.toString();
} else if (value instanceof String) {
return "'"+((String) value).replaceAll("'","''")+"'";
}
return database.getDateTimeLiteral(((java.sql.Timestamp) value));
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:DateTimeType.java
示例4: setValueNumeric
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public ColumnConfig setValueNumeric(String valueNumeric) {
if (valueNumeric == null || valueNumeric.equalsIgnoreCase("null")) {
this.valueNumeric = null;
} else {
valueNumeric = valueNumeric.replaceFirst("^\\(", "");
valueNumeric = valueNumeric.replaceFirst("\\)$", "");
if (valueNumeric.matches("\\d+\\.?\\d*")) {
try {
this.valueNumeric = NumberFormat.getInstance(Locale.US).
parse(valueNumeric);
} catch (ParseException e) {
throw new RuntimeException(e);
}
} else {
this.valueComputed = new DatabaseFunction(valueNumeric);
}
}
return this;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:ColumnConfig.java
示例5: setDefaultValueNumeric
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public ColumnConfig setDefaultValueNumeric(String defaultValueNumeric) throws ParseException {
if (defaultValueNumeric == null || defaultValueNumeric.equalsIgnoreCase("null")) {
this.defaultValueNumeric = null;
} else {
if ("GENERATED_BY_DEFAULT".equals(defaultValueNumeric)) {
setAutoIncrement(true);
} else {
defaultValueNumeric = defaultValueNumeric.replaceFirst("^\\(", "");
defaultValueNumeric = defaultValueNumeric.replaceFirst("\\)$", "");
try {
this.defaultValueNumeric = NumberFormat.getInstance(Locale.US).parse(defaultValueNumeric);
} catch (ParseException e) {
this.defaultValueComputed = new DatabaseFunction(defaultValueNumeric);
}
}
}
return this;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:20,代码来源:ColumnConfig.java
示例6: objectToSql
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
/**
* @see liquibase.datatype.LiquibaseDataType#objectToSql(java.lang.Object,
* liquibase.database.Database)
*/
@Override
public String objectToSql(final Object value, final Database database) {
final String returnValue;
if (value instanceof Geometry) {
// TODO: Tailor the output for the database.
returnValue = ((Geometry) value).toText();
} else if (value instanceof String) {
returnValue = value.toString();
} else if (value instanceof DatabaseFunction) {
returnValue = value.toString();
} else if (value == null || value.toString().equalsIgnoreCase("null")) {
returnValue = null;
} else {
throw new UnexpectedLiquibaseException("Cannot convert type " + value.getClass()
+ " to a Geometry value");
}
return returnValue;
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:23,代码来源:GeometryType.java
示例7: generateValues
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
private void generateValues(StringBuilder sql, HiveInsertStatement statement, Database database) {
sql.append("(");
for (Object newValue : statement.getColumnValues()) {
if (newValue == null || newValue.toString().equalsIgnoreCase("NULL")) {
sql.append("NULL");
} else if (newValue instanceof String && !looksLikeFunctionCall(((String) newValue), database)) {
sql.append(DataTypeFactory.getInstance().fromObject(newValue, database).objectToSql(newValue, database));
} else if (newValue instanceof Date) {
sql.append(database.getDateLiteral(((Date) newValue)));
} else if (newValue instanceof Boolean) {
if (((Boolean) newValue)) {
sql.append(DataTypeFactory.getInstance().getTrueBooleanValue(database));
} else {
sql.append(DataTypeFactory.getInstance().getFalseBooleanValue(database));
}
} else if (newValue instanceof DatabaseFunction) {
sql.append(database.generateDatabaseFunctionValue((DatabaseFunction) newValue));
} else {
sql.append(newValue);
}
sql.append(", ");
}
sql.deleteCharAt(sql.lastIndexOf(" "));
int lastComma = sql.lastIndexOf(",");
if (lastComma >= 0) {
sql.deleteCharAt(lastComma);
}
sql.append(")");
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:33,代码来源:HiveInsertGenerator.java
示例8: objectToSql
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
@Override
public String objectToSql(Object value, Database database) {
if (value == null || value.toString().equalsIgnoreCase("null")) {
return null;
} else if (value instanceof DatabaseFunction) {
return database.generateDatabaseFunctionValue((DatabaseFunction) value);
} else if (database.isFunction(value.toString())) {
return value.toString();
} else if (value instanceof String) {
return "'" + ((String) value).replaceAll("'", "''") + "'";
}
return database.getDateTimeLiteral(((java.sql.Timestamp) value));
}
开发者ID:liquibase,项目名称:liquibase-sqlfire,代码行数:14,代码来源:DateTimeType.java
示例9: getDataType
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public DataType getDataType(Object object) {
if (object instanceof BigInteger) {
return getBigIntType();
} else if (object instanceof Boolean) {
return getBooleanType();
} else if (object instanceof String) {
return getVarcharType();
} else if (object instanceof java.sql.Date) {
return getDateType();
} else if (object instanceof java.sql.Timestamp) {
return getDateTimeType();
} else if (object instanceof java.sql.Time) {
return getTimeType();
} else if (object instanceof java.util.Date) {
return getDateTimeType();
} else if (object instanceof Double) {
return getDoubleType();
} else if (object instanceof Float) {
return getFloatType();
} else if (object instanceof Integer) {
return getIntType();
} else if (object instanceof Long) {
return getBigIntType();
} else if (object instanceof DatabaseFunction) {
return new DatabaseFunctionType();
} else {
throw new UnexpectedLiquibaseException("Unknown object type "+object.getClass().getName());
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:30,代码来源:AbstractTypeConverter.java
示例10: setProperty
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public static void setProperty(Object object, String propertyName, String propertyValue) throws IllegalAccessException, InvocationTargetException {
String methodName = "set" + propertyName.substring(0, 1).toUpperCase(Locale.ENGLISH) + propertyName.substring(1);
Method[] methods;
methods = methodCache.get(object.getClass());
if (methods == null) {
methods = object.getClass().getMethods();
methodCache.put(object.getClass(), methods);
}
for (Method method : methods) {
if (method.getName().equals(methodName)) {
Class<?> parameterType = method.getParameterTypes()[0];
if (method.getParameterTypes().length == 1) {
if (parameterType.equals(Boolean.class)) {
method.invoke(object, Boolean.valueOf(propertyValue));
return;
} else if (parameterType.equals(String.class)) {
method.invoke(object, propertyValue);
return;
} else if (parameterType.equals(Integer.class)) {
method.invoke(object, Integer.valueOf(propertyValue));
return;
} else if (parameterType.equals(Long.class)) {
method.invoke(object, Long.valueOf(propertyValue));
return;
} else if (parameterType.equals(BigInteger.class)) {
method.invoke(object, new BigInteger(propertyValue));
return;
} else if (parameterType.equals(DatabaseFunction.class)) {
method.invoke(object, new DatabaseFunction(propertyValue));
return;
}
}
}
}
throw new RuntimeException("Property '" + propertyName+"' not found on object type "+object.getClass().getName());
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:40,代码来源:ObjectUtil.java
示例11: setValueDate
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public ColumnConfig setValueDate(String valueDate) {
if (valueDate == null || valueDate.equalsIgnoreCase("null")) {
this.valueDate = null;
} else {
try {
this.valueDate = new ISODateFormat().parse(valueDate);
} catch (ParseException e) {
//probably a function
this.valueComputed = new DatabaseFunction(valueDate);
}
}
return this;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:15,代码来源:ColumnConfig.java
示例12: setDefaultValueDate
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public ColumnConfig setDefaultValueDate(String defaultValueDate) {
if (defaultValueDate == null || defaultValueDate.equalsIgnoreCase("null")) {
this.defaultValueDate = null;
} else {
try {
this.defaultValueDate = new ISODateFormat().parse(defaultValueDate);
} catch (ParseException e) {
//probably a computed date
this.defaultValueComputed = new DatabaseFunction(defaultValueDate);
}
}
return this;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:15,代码来源:ColumnConfig.java
示例13: generateStatements
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public SqlStatement[] generateStatements(Database database) {
if (database instanceof PostgresDatabase) {
String sequenceName = (getTableName() + "_" + getColumnName() + "_seq").toLowerCase();
return new SqlStatement[]{
new CreateSequenceStatement(schemaName, sequenceName),
new SetNullableStatement(schemaName, getTableName(), getColumnName(), null, false),
new AddDefaultValueStatement(schemaName, getTableName(), getColumnName(), getColumnDataType(), new DatabaseFunction("NEXTVAL('"+sequenceName+"')")),
};
}
return new SqlStatement[]{new AddAutoIncrementStatement(getSchemaName(), getTableName(), getColumnName(), getColumnDataType(), getStartWith(), getIncrementBy())};
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:13,代码来源:AddAutoIncrementChange.java
示例14: generateStatements
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public SqlStatement[] generateStatements(final Database database) {
final List<SqlStatement> statements = new ArrayList<SqlStatement>();
if (database instanceof PostgresDatabase) {
String sequenceName = m_sequenceName;
if (m_sequenceName == null) {
sequenceName = (getTableName() + "_" + getColumnName() + "_seq").toLowerCase();
statements.add(new CreateSequenceStatement(getSchemaName(), sequenceName));
}
statements.add(new SetNullableStatement(getSchemaName(), getTableName(), getColumnName(), null, false));
statements.add(new AddDefaultValueStatement(getSchemaName(), getTableName(), getColumnName(), getColumnDataType(), new DatabaseFunction("NEXTVAL('"+sequenceName+"')")));
return statements.toArray(new SqlStatement[0]);
} else {
return super.generateStatements(database);
}
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:16,代码来源:AddNamedAutoIncrementChange.java
示例15: TimestenDatabase
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public TimestenDatabase() {
super.setCurrentDateTimeFunction("TT_SYSDATE");
// Setting list of Timesten native functions
dateFunctions.add(new DatabaseFunction("SYSDATE"));
dateFunctions.add(new DatabaseFunction("GETDATE"));
}
开发者ID:mbocek,项目名称:liquibase-timesten,代码行数:7,代码来源:TimestenDatabase.java
示例16: objectToSql
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
@Override
public String objectToSql(Object value, Database database) {
if (value == null || value.toString().equalsIgnoreCase("null")) {
return null;
}
String returnValue;
if (value instanceof String) {
if (((String) value).equalsIgnoreCase("true") || value.equals("1") || value.equals("t") || ((String) value).equalsIgnoreCase(this.getTrueBooleanValue(database))) {
returnValue = this.getTrueBooleanValue(database);
} else if (((String) value).equalsIgnoreCase("false") || value.equals("0") || value.equals("f") || ((String) value).equalsIgnoreCase(this.getFalseBooleanValue(database))) {
returnValue = this.getFalseBooleanValue(database);
} else {
throw new UnexpectedLiquibaseException("Unknown boolean value: " + value);
}
} else if (value instanceof Long) {
if (Long.valueOf(1).equals(value)) {
returnValue = this.getTrueBooleanValue(database);
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else if (value instanceof Integer) {
if (1 == (Integer) value) {
returnValue = this.getTrueBooleanValue(database);
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else if (value instanceof DatabaseFunction) {
return value.toString();
} else if (value instanceof Boolean) {
if (((Boolean) value)) {
returnValue = this.getTrueBooleanValue(database);
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else {
throw new UnexpectedLiquibaseException("Cannot convert type "+value.getClass()+" to a boolean value");
}
return returnValue;
}
开发者ID:liquibase,项目名称:liquibase-sqlfire,代码行数:42,代码来源:BooleanType.java
示例17: generateSql
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public Sql[] generateSql(MarkChangeSetRanStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String dateValue = database.getCurrentDateTimeFunction();
ChangeSet changeSet = statement.getChangeSet();
SqlStatement runStatement;
try {
if (statement.getExecType().equals(ChangeSet.ExecType.FAILED) || statement.getExecType().equals(ChangeSet.ExecType.SKIPPED)) {
return new Sql[0]; //don't mark
} else if (statement.getExecType().ranBefore) {
runStatement = new UpdateStatement(database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName())
.addNewColumnValue("DATEEXECUTED", new DatabaseFunction(dateValue))
.addNewColumnValue("MD5SUM", changeSet.generateCheckSum().toString())
.addNewColumnValue("EXECTYPE", statement.getExecType().value)
.setWhereClause("ID=? AND AUTHOR=? AND FILENAME=?")
.addWhereParameters(changeSet.getId(), changeSet.getAuthor(), changeSet.getFilePath());
} else {
runStatement = new InsertStatement(database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName())
.addColumnValue("ID", changeSet.getId())
.addColumnValue("AUTHOR", changeSet.getAuthor())
.addColumnValue("FILENAME", changeSet.getFilePath())
.addColumnValue("DATEEXECUTED", new DatabaseFunction(dateValue))
.addColumnValue("ORDEREXECUTED", database.getNextChangeSetSequenceValue())
.addColumnValue("MD5SUM", changeSet.generateCheckSum().toString())
.addColumnValue("DESCRIPTION", limitSize(changeSet.getDescription()))
.addColumnValue("COMMENTS", limitSize(StringUtils.trimToEmpty(changeSet.getComments())))
.addColumnValue("EXECTYPE", statement.getExecType().value)
.addColumnValue("LIQUIBASE", LiquibaseUtil.getBuildVersion().replaceAll("SNAPSHOT", "SNP"));
String tag = null;
List<Change> changes = changeSet.getChanges();
if (changes != null && changes.size() == 1) {
Change change = changes.get(0);
if (change instanceof TagDatabaseChange) {
TagDatabaseChange tagChange = (TagDatabaseChange) change;
tag = tagChange.getTag();
}
}
if (tag != null) {
((InsertStatement) runStatement).addColumnValue("TAG", tag);
}
}
} catch (LiquibaseException e) {
throw new UnexpectedLiquibaseException(e);
}
return SqlGeneratorFactory.getInstance().generateSql(runStatement, database);
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:49,代码来源:MarkChangeSetRanGenerator.java
示例18: H2Database
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public H2Database() {
this.databaseFunctions.add(new DatabaseFunction("CURRENT_TIMESTAMP()"));
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:4,代码来源:H2Database.java
示例19: OracleDatabase
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public OracleDatabase() {
// Setting list of Oracle's native functions
databaseFunctions.add(new DatabaseFunction("SYSDATE"));
databaseFunctions.add(new DatabaseFunction("SYSTIMESTAMP"));
databaseFunctions.add(new DatabaseFunction("CURRENT_TIMESTAMP"));
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:7,代码来源:OracleDatabase.java
示例20: getValueComputed
import liquibase.statement.DatabaseFunction; //导入依赖的package包/类
public DatabaseFunction getValueComputed() {
return valueComputed;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:4,代码来源:ColumnConfig.java
注:本文中的liquibase.statement.DatabaseFunction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论