本文整理汇总了Java中com.j256.ormlite.db.DatabaseType类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseType类的具体用法?Java DatabaseType怎么用?Java DatabaseType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseType类属于com.j256.ormlite.db包,在下文中一共展示了DatabaseType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: appendWhereIds
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static void appendWhereIds(DatabaseType paramDatabaseType, FieldType paramFieldType, StringBuilder paramStringBuilder, int paramInt, FieldType[] paramArrayOfFieldType)
{
paramStringBuilder.append("WHERE ");
paramDatabaseType.appendEscapedEntityName(paramStringBuilder, paramFieldType.getColumnName());
paramStringBuilder.append(" IN (");
int i = 1;
for (int j = 0; j < paramInt; j++)
{
if (i != 0)
i = 0;
else
paramStringBuilder.append(',');
paramStringBuilder.append('?');
if (paramArrayOfFieldType != null)
paramArrayOfFieldType[j] = paramFieldType;
}
paramStringBuilder.append(") ");
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:19,代码来源:MappedDeleteCollection.java
示例2: appendSql
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
public void appendSql(DatabaseType paramDatabaseType, String paramString, StringBuilder paramStringBuilder, List<ArgumentHolder> paramList)
{
if ((this.comparison == null) && (this.exists == null))
throw new IllegalStateException("Clause has not been set in NOT operation");
if (this.comparison == null)
{
paramStringBuilder.append("(NOT ");
this.exists.appendSql(paramDatabaseType, paramString, paramStringBuilder, paramList);
}
else
{
paramStringBuilder.append("(NOT ");
if (paramString != null)
{
paramDatabaseType.appendEscapedEntityName(paramStringBuilder, paramString);
paramStringBuilder.append('.');
}
paramDatabaseType.appendEscapedEntityName(paramStringBuilder, this.comparison.getColumnName());
paramStringBuilder.append(' ');
this.comparison.appendOperation(paramStringBuilder);
this.comparison.appendValue(paramDatabaseType, paramStringBuilder, paramList);
}
paramStringBuilder.append(") ");
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:25,代码来源:Not.java
示例3: appendSql
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
public void appendSql(DatabaseType paramDatabaseType, String paramString, StringBuilder paramStringBuilder, List<ArgumentHolder> paramList)
{
paramStringBuilder.append("(");
this.first.appendSql(paramDatabaseType, paramString, paramStringBuilder, paramList);
if (this.second != null)
{
paramStringBuilder.append(this.operation);
paramStringBuilder.append(' ');
this.second.appendSql(paramDatabaseType, paramString, paramStringBuilder, paramList);
}
if (this.others != null)
for (int i = this.startOthersAt; i < this.others.length; i++)
{
paramStringBuilder.append(this.operation);
paramStringBuilder.append(' ');
this.others[i].appendSql(paramDatabaseType, paramString, paramStringBuilder, paramList);
}
paramStringBuilder.append(") ");
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:ManyClause.java
示例4: appendValue
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
public void appendValue(DatabaseType paramDatabaseType, StringBuilder paramStringBuilder, List<ArgumentHolder> paramList)
{
paramStringBuilder.append('(');
int i = 1;
Iterator localIterator = this.objects.iterator();
while (localIterator.hasNext())
{
Object localObject = localIterator.next();
if (localObject == null)
throw new IllegalArgumentException("one of the IN values for '" + this.columnName + "' is null");
if (i != 0)
i = 0;
else
paramStringBuilder.append(',');
super.appendArgOrValue(paramDatabaseType, this.fieldType, paramStringBuilder, paramList, localObject);
}
paramStringBuilder.append(") ");
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:19,代码来源:In.java
示例5: fromForeignCollection
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static DatabaseFieldConfig fromForeignCollection(DatabaseType paramDatabaseType, Field paramField, ForeignCollectionField paramForeignCollectionField)
{
DatabaseFieldConfig localDatabaseFieldConfig = new DatabaseFieldConfig();
localDatabaseFieldConfig.fieldName = paramField.getName();
if (paramForeignCollectionField.columnName().length() > 0)
localDatabaseFieldConfig.columnName = paramForeignCollectionField.columnName();
localDatabaseFieldConfig.foreignCollection = true;
localDatabaseFieldConfig.foreignCollectionEager = paramForeignCollectionField.eager();
int i = paramForeignCollectionField.maxEagerForeignCollectionLevel();
if (i != 1)
localDatabaseFieldConfig.foreignCollectionMaxEagerLevel = i;
else
localDatabaseFieldConfig.foreignCollectionMaxEagerLevel = paramForeignCollectionField.maxEagerLevel();
localDatabaseFieldConfig.foreignCollectionOrderColumnName = valueIfNotBlank(paramForeignCollectionField.orderColumnName());
localDatabaseFieldConfig.foreignCollectionOrderAscending = paramForeignCollectionField.orderAscending();
localDatabaseFieldConfig.foreignCollectionColumnName = valueIfNotBlank(paramForeignCollectionField.columnName());
String str = valueIfNotBlank(paramForeignCollectionField.foreignFieldName());
if (str == null)
{
localDatabaseFieldConfig.foreignCollectionForeignFieldName = valueIfNotBlank(valueIfNotBlank(paramForeignCollectionField.foreignColumnName()));
return localDatabaseFieldConfig;
}
localDatabaseFieldConfig.foreignCollectionForeignFieldName = str;
return localDatabaseFieldConfig;
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:26,代码来源:DatabaseFieldConfig.java
示例6: configFromField
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static DatabaseFieldConfig configFromField(DatabaseType paramDatabaseType, String paramString, Field paramField)
{
if (configFieldNums == null)
return DatabaseFieldConfig.fromField(paramDatabaseType, paramString, paramField);
DatabaseField localDatabaseField = (DatabaseField)paramField.getAnnotation(DatabaseField.class);
DatabaseFieldConfig localDatabaseFieldConfig = null;
if (localDatabaseField != null);
try
{
localDatabaseFieldConfig = buildConfig(localDatabaseField, paramString, paramField);
}
catch (Exception localException)
{
}
if (localDatabaseFieldConfig == null)
return DatabaseFieldConfig.fromField(paramDatabaseType, paramString, paramField);
workedC = 1 + workedC;
return localDatabaseFieldConfig;
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:DatabaseTableConfigUtil.java
示例7: fromClass
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
public static <T> DatabaseTableConfig<T> fromClass(ConnectionSource paramConnectionSource, Class<T> paramClass)
{
DatabaseType localDatabaseType = paramConnectionSource.getDatabaseType();
String str = DatabaseTableConfig.extractTableName(paramClass);
ArrayList localArrayList = new ArrayList();
for (Object localObject = paramClass; localObject != null; localObject = ((Class)localObject).getSuperclass())
{
Field[] arrayOfField = ((Class)localObject).getDeclaredFields();
int i = arrayOfField.length;
for (int j = 0; j < i; j++)
{
DatabaseFieldConfig localDatabaseFieldConfig = configFromField(localDatabaseType, str, arrayOfField[j]);
if ((localDatabaseFieldConfig != null) && (localDatabaseFieldConfig.isPersisted()))
localArrayList.add(localDatabaseFieldConfig);
}
}
if (localArrayList.size() == 0)
return null;
return new DatabaseTableConfig(paramClass, str, localArrayList);
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:DatabaseTableConfigUtil.java
示例8: addDropIndexStatements
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static <T, ID> void addDropIndexStatements(DatabaseType paramDatabaseType, TableInfo<T, ID> paramTableInfo, List<String> paramList)
{
HashSet localHashSet = new HashSet();
for (FieldType localFieldType : paramTableInfo.getFieldTypes())
{
String str2 = localFieldType.getIndexName();
if (str2 != null)
localHashSet.add(str2);
String str3 = localFieldType.getUniqueIndexName();
if (str3 != null)
localHashSet.add(str3);
}
StringBuilder localStringBuilder = new StringBuilder(48);
Iterator localIterator = localHashSet.iterator();
while (localIterator.hasNext())
{
String str1 = (String)localIterator.next();
logger.info("dropping index '{}' for table '{}", str1, paramTableInfo.getTableName());
localStringBuilder.append("DROP INDEX ");
paramDatabaseType.appendEscapedEntityName(localStringBuilder, str1);
paramList.add(localStringBuilder.toString());
localStringBuilder.setLength(0);
}
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:25,代码来源:TableUtils.java
示例9: addDropTableStatements
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static <T, ID> void addDropTableStatements(DatabaseType paramDatabaseType, TableInfo<T, ID> paramTableInfo, List<String> paramList)
{
ArrayList localArrayList1 = new ArrayList();
ArrayList localArrayList2 = new ArrayList();
FieldType[] arrayOfFieldType = paramTableInfo.getFieldTypes();
int i = arrayOfFieldType.length;
for (int j = 0; j < i; j++)
paramDatabaseType.dropColumnArg(arrayOfFieldType[j], localArrayList1, localArrayList2);
StringBuilder localStringBuilder = new StringBuilder(64);
localStringBuilder.append("DROP TABLE ");
paramDatabaseType.appendEscapedEntityName(localStringBuilder, paramTableInfo.getTableName());
localStringBuilder.append(' ');
paramList.addAll(localArrayList1);
paramList.add(localStringBuilder.toString());
paramList.addAll(localArrayList2);
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:17,代码来源:TableUtils.java
示例10: doCreateTable
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static <T, ID> int doCreateTable(ConnectionSource paramConnectionSource, TableInfo<T, ID> paramTableInfo, boolean paramBoolean)
{
DatabaseType localDatabaseType = paramConnectionSource.getDatabaseType();
logger.info("creating table '{}'", paramTableInfo.getTableName());
ArrayList localArrayList1 = new ArrayList();
ArrayList localArrayList2 = new ArrayList();
addCreateTableStatements(localDatabaseType, paramTableInfo, localArrayList1, localArrayList2, paramBoolean);
DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadWriteConnection();
try
{
int i = doStatements(localDatabaseConnection, "create", localArrayList1, false, localDatabaseType.isCreateTableReturnsNegative(), localDatabaseType.isCreateTableReturnsZero()) + doCreateTestQueries(localDatabaseConnection, localDatabaseType, localArrayList2);
return i;
}
finally
{
paramConnectionSource.releaseConnection(localDatabaseConnection);
}
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:19,代码来源:TableUtils.java
示例11: doDropTable
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static <T, ID> int doDropTable(DatabaseType paramDatabaseType, ConnectionSource paramConnectionSource, TableInfo<T, ID> paramTableInfo, boolean paramBoolean)
{
logger.info("dropping table '{}'", paramTableInfo.getTableName());
ArrayList localArrayList = new ArrayList();
addDropIndexStatements(paramDatabaseType, paramTableInfo, localArrayList);
addDropTableStatements(paramDatabaseType, paramTableInfo, localArrayList);
DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadWriteConnection();
try
{
int i = doStatements(localDatabaseConnection, "drop", localArrayList, paramBoolean, paramDatabaseType.isCreateTableReturnsNegative(), false);
return i;
}
finally
{
paramConnectionSource.releaseConnection(localDatabaseConnection);
}
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:18,代码来源:TableUtils.java
示例12: clearTable
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
public static int clearTable(ConnectionSource connectionSource, String tableName) throws SQLException {
FieldType[] noFieldTypes = new FieldType[0];
DatabaseType databaseType = connectionSource.getDatabaseType();
StringBuilder sb = new StringBuilder(48);
if (databaseType.isTruncateSupported()) {
sb.append("TRUNCATE TABLE ");
} else {
sb.append("DELETE FROM ");
}
databaseType.appendEscapedEntityName(sb, tableName);
String statement = sb.toString();
Log.i("DatabaseHelper", "clearing table '" + tableName + "' with '" + statement + "'");
CompiledStatement compiledStmt = null;
DatabaseConnection connection = connectionSource.getReadWriteConnection();
try {
compiledStmt =
connection.compileStatement(statement, StatementBuilder.StatementType.EXECUTE, noFieldTypes,
DatabaseConnection.DEFAULT_RESULT_FLAGS);
return compiledStmt.runExecute();
} finally {
if (compiledStmt != null) {
compiledStmt.close();
}
connectionSource.releaseConnection(connection);
}
}
开发者ID:padc,项目名称:DevConSummit,代码行数:27,代码来源:Util.java
示例13: fromClass
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
/**
* Build our list table config from a class using some annotation fu around.
*/
public static <T> DatabaseTableConfig<T> fromClass(ConnectionSource connectionSource, Class<T> clazz)
throws SQLException {
DatabaseType databaseType = connectionSource.getDatabaseType();
String tableName = DatabaseTableConfig.extractTableName(clazz);
List<DatabaseFieldConfig> fieldConfigs = new ArrayList<DatabaseFieldConfig>();
for (Class<?> classWalk = clazz; classWalk != null; classWalk = classWalk.getSuperclass()) {
for (Field field : classWalk.getDeclaredFields()) {
DatabaseFieldConfig config = configFromField(databaseType, tableName, field);
if (config != null && config.isPersisted()) {
fieldConfigs.add(config);
}
}
}
if (fieldConfigs.size() == 0) {
return null;
} else {
return new DatabaseTableConfig<T>(clazz, tableName, fieldConfigs);
}
}
开发者ID:d-tarasov,项目名称:ormlite-android-sqlcipher,代码行数:23,代码来源:DatabaseTableConfigUtil.java
示例14: testConstructors
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
@Test
public void testConstructors() throws Exception {
JdbcPooledConnectionSource pooled = new JdbcPooledConnectionSource(DEFAULT_DATABASE_URL);
assertEquals(DEFAULT_DATABASE_URL, pooled.getUrl());
pooled.close();
pooled = new JdbcPooledConnectionSource(DEFAULT_DATABASE_URL, null, null);
assertEquals(DEFAULT_DATABASE_URL, pooled.getUrl());
pooled.close();
DatabaseType databaseType = DatabaseTypeUtils.createDatabaseType(DEFAULT_DATABASE_URL);
pooled = new JdbcPooledConnectionSource(DEFAULT_DATABASE_URL, databaseType);
assertEquals(DEFAULT_DATABASE_URL, pooled.getUrl());
assertSame(databaseType, pooled.getDatabaseType());
pooled.close();
pooled = new JdbcPooledConnectionSource(DEFAULT_DATABASE_URL, null, null, databaseType);
assertEquals(DEFAULT_DATABASE_URL, pooled.getUrl());
assertSame(databaseType, pooled.getDatabaseType());
pooled.close();
}
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:22,代码来源:JdbcPooledConnectionSourceTest.java
示例15: isFieldCreatable
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static boolean isFieldCreatable(DatabaseType databaseType, FieldType fieldType) {
// we don't insert anything if it is a collection
if (fieldType.isForeignCollection()) {
// skip foreign collections
return false;
} else if (fieldType.isReadOnly()) {
// ignore read-only fields
return false;
} else if (databaseType.isIdSequenceNeeded() && databaseType.isSelectSequenceBeforeInsert()) {
// we need to query for the next value from the sequence and the idField is inserted afterwards
return true;
} else if (fieldType.isGeneratedId() && !fieldType.isSelfGeneratedId() && !fieldType.isAllowGeneratedIdInsert()) {
// skip generated-id fields because they will be auto-inserted
return false;
} else {
return true;
}
}
开发者ID:j256,项目名称:ormlite-core,代码行数:19,代码来源:MappedCreate.java
示例16: appendWhereIds
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
private static void appendWhereIds(DatabaseType databaseType, FieldType idField, StringBuilder sb, int numDatas,
FieldType[] fieldTypes) {
sb.append("WHERE ");
databaseType.appendEscapedEntityName(sb, idField.getColumnName());
sb.append(" IN (");
boolean first = true;
for (int i = 0; i < numDatas; i++) {
if (first) {
first = false;
} else {
sb.append(',');
}
sb.append('?');
if (fieldTypes != null) {
fieldTypes[i] = idField;
}
}
sb.append(") ");
}
开发者ID:j256,项目名称:ormlite-core,代码行数:20,代码来源:MappedDeleteCollection.java
示例17: appendSql
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
@Override
public void appendSql(DatabaseType databaseType, String tableName, StringBuilder sb,
List<ArgumentHolder> selectArgList) throws SQLException {
if (comparison == null && exists == null) {
throw new IllegalStateException("Clause has not been set in NOT operation");
}
// this generates: (NOT 'x' = 123 )
if (comparison == null) {
sb.append("(NOT ");
exists.appendSql(databaseType, tableName, sb, selectArgList);
} else {
sb.append("(NOT ");
if (tableName != null) {
databaseType.appendEscapedEntityName(sb, tableName);
sb.append('.');
}
databaseType.appendEscapedEntityName(sb, comparison.getColumnName());
sb.append(' ');
comparison.appendOperation(sb);
comparison.appendValue(databaseType, sb, selectArgList);
}
sb.append(") ");
}
开发者ID:j256,项目名称:ormlite-core,代码行数:24,代码来源:Not.java
示例18: appendSql
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
@Override
public void appendSql(DatabaseType databaseType, String tableName, StringBuilder sb,
List<ArgumentHolder> selectArgList) throws SQLException {
sb.append('(');
first.appendSql(databaseType, tableName, sb, selectArgList);
if (second != null) {
sb.append(operation);
sb.append(' ');
second.appendSql(databaseType, tableName, sb, selectArgList);
}
if (others != null) {
for (int i = startOthersAt; i < others.length; i++) {
sb.append(operation);
sb.append(' ');
others[i].appendSql(databaseType, tableName, sb, selectArgList);
}
}
sb.append(") ");
}
开发者ID:j256,项目名称:ormlite-core,代码行数:20,代码来源:ManyClause.java
示例19: appendValue
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
@Override
public void appendValue(DatabaseType databaseType, StringBuilder sb, List<ArgumentHolder> columnArgList)
throws SQLException {
sb.append('(');
boolean first = true;
for (Object value : objects) {
if (value == null) {
throw new IllegalArgumentException("one of the IN values for '" + columnName + "' is null");
}
if (first) {
first = false;
} else {
sb.append(',');
}
// for each of our arguments, add it to the output
super.appendArgOrValue(databaseType, fieldType, sb, columnArgList, value);
}
sb.append(") ");
}
开发者ID:j256,项目名称:ormlite-core,代码行数:20,代码来源:In.java
示例20: appendValue
import com.j256.ormlite.db.DatabaseType; //导入依赖的package包/类
@Override
public void appendValue(DatabaseType databaseType, StringBuilder sb, List<ArgumentHolder> argList)
throws SQLException {
sb.append('(');
subQueryBuilder.appendStatementString(sb, argList);
FieldType[] resultFieldTypes = subQueryBuilder.getResultFieldTypes();
if (resultFieldTypes == null) {
// we assume that if someone is doing a raw select, they know what they are doing
} else if (resultFieldTypes.length != 1) {
throw new SQLException("There must be only 1 result column in sub-query but we found "
+ resultFieldTypes.length);
} else if (fieldType.getSqlType() != resultFieldTypes[0].getSqlType()) {
throw new SQLException("Outer column " + fieldType + " is not the same type as inner column "
+ resultFieldTypes[0]);
}
sb.append(") ");
}
开发者ID:j256,项目名称:ormlite-core,代码行数:18,代码来源:InSubQuery.java
注:本文中的com.j256.ormlite.db.DatabaseType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论