本文整理汇总了Java中com.j256.ormlite.field.FieldType.getGeneratedIdSequence方法的典型用法代码示例。如果您正苦于以下问题:Java FieldType.getGeneratedIdSequence方法的具体用法?Java FieldType.getGeneratedIdSequence怎么用?Java FieldType.getGeneratedIdSequence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.field.FieldType
的用法示例。
在下文中一共展示了FieldType.getGeneratedIdSequence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildQueryNextSequence
import com.j256.ormlite.field.FieldType; //导入方法依赖的package包/类
private static String buildQueryNextSequence(DatabaseType paramDatabaseType, FieldType paramFieldType)
{
if (paramFieldType == null)
return null;
String str = paramFieldType.getGeneratedIdSequence();
if (str == null)
return null;
StringBuilder localStringBuilder = new StringBuilder(64);
paramDatabaseType.appendSelectNextValFromSequence(localStringBuilder, str);
return localStringBuilder.toString();
}
示例2: configureGeneratedIdSequence
import com.j256.ormlite.field.FieldType; //导入方法依赖的package包/类
@Override
protected void configureGeneratedIdSequence(StringBuilder sb, FieldType fieldType, List<String> statementsBefore,
List<String> additionalArgs, List<String> queriesAfter) {
String sequenceName = fieldType.getGeneratedIdSequence();
// added existence check
// !! this check will only detect if there is a something with the given name present,
// even though the object in question might not be a SEQUENCE
StringBuilder seqSb = new StringBuilder();
seqSb.append("do $$\nBEGIN\n");
seqSb.append("IF NOT EXISTS (SELECT 0 FROM pg_class where relname = '");
seqSb.append(sequenceName);
seqSb.append("' )\n" +
"THEN\n" +
"CREATE SEQUENCE ");
appendEscapedEntityName(seqSb, sequenceName);
seqSb.append(";\nEND IF;\nEND\n$$");
statementsBefore.add(seqSb.toString());
sb.append("DEFAULT NEXTVAL(");
// postgres needed this special escaping for NEXTVAL('"sequence-name"')
sb.append('\'').append('\"').append(sequenceName).append('\"').append('\'');
sb.append(") ");
// could also be the type serial for auto-generated sequences
// 8.2 also have the returning insert statement
configureId(sb, fieldType, statementsBefore, additionalArgs, queriesAfter);
}