当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseField.generatedId方法代码示例

本文整理汇总了Java中com.j256.ormlite.field.DatabaseField.generatedId方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseField.generatedId方法的具体用法?Java DatabaseField.generatedId怎么用?Java DatabaseField.generatedId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.j256.ormlite.field.DatabaseField的用法示例。


在下文中一共展示了DatabaseField.generatedId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findIdField

import com.j256.ormlite.field.DatabaseField; //导入方法依赖的package包/类
/**
 * Find a Field with a DatabaseField annotation that defines it as being an id column.
 *
 * @param annotationRetriever the annotation retriever that caches the annotations
 * @param modelClass          the class to find the ID field in
 * @return the Field or null
 */
@Nullable
public static Field findIdField(AnnotationRetriever annotationRetriever, Class<?> modelClass) {
	for (Field field : modelClass.getDeclaredFields()) {
		DatabaseField database_field = annotationRetriever.getAnnotation(field, DatabaseField.class);

		if (database_field == null) {
			continue;
		}

		if (database_field.generatedId() || database_field.id()) {
			return field;
		}
	}

	if (modelClass.getSuperclass() == null) {
		return null;
	}

	// Recursively check superclass
	return findIdField(annotationRetriever, modelClass.getSuperclass());
}
 
开发者ID:ByteWelder,项目名称:Poetry,代码行数:29,代码来源:OrmliteReflection.java

示例2: fromDatabaseField

import com.j256.ormlite.field.DatabaseField; //导入方法依赖的package包/类
public static FieldBindings fromDatabaseField(DatabaseType databaseType, Element field, DatabaseField databaseField, Types typeUtils, Messager messager) {
    FieldBindings bindings = new FieldBindings();
    bindings.fieldName = field.getSimpleName().toString();
    if (databaseType.isEntityNamesMustBeUpCase()) {
        bindings.fieldName = bindings.fieldName.toUpperCase();
    }
    bindings.columnName = valueIfNotBlank(databaseField.columnName());
    bindings.dataType = databaseField.dataType();
    // NOTE: == did not work with the NO_DEFAULT string
    String defaultValue = databaseField.defaultValue();
    if (!defaultValue.equals(DatabaseField.DEFAULT_STRING)) {
        bindings.defaultValue = defaultValue;
    }
    bindings.width = databaseField.width();
    bindings.canBeNull = databaseField.canBeNull();
    bindings.id = databaseField.id();
    bindings.generatedId = databaseField.generatedId();
    bindings.generatedIdSequence = valueIfNotBlank(databaseField.generatedIdSequence());
    bindings.foreign = databaseField.foreign();
    bindings.useGetSet = databaseField.useGetSet();
    bindings.unknownEnumValue = findMatchingEnumVal(field, databaseField.unknownEnumName(), messager);
    bindings.throwIfNull = databaseField.throwIfNull();
    bindings.format = valueIfNotBlank(databaseField.format());
    bindings.unique = databaseField.unique();
    bindings.uniqueCombo = databaseField.uniqueCombo();
    // add in the index information
    bindings.index = databaseField.index();
    bindings.indexName = valueIfNotBlank(databaseField.indexName());
    bindings.uniqueIndex = databaseField.uniqueIndex();
    bindings.uniqueIndexName = valueIfNotBlank(databaseField.uniqueIndexName());
    bindings.foreignAutoRefresh = databaseField.foreignAutoRefresh();
    bindings.maxForeignAutoRefreshLevel = databaseField.maxForeignAutoRefreshLevel();
    try {
        databaseField.persisterClass();
    } catch (MirroredTypeException e) {
        Element element = typeUtils.asElement(e.getTypeMirror());
        if (!element.getKind().equals(ElementKind.CLASS)) {
            messager.printMessage(Diagnostic.Kind.ERROR, "persisterClass must be a class", element);
            return null;
        }
        bindings.persisterClass = (TypeElement) element;
    }
    bindings.allowGeneratedIdInsert = databaseField.allowGeneratedIdInsert();
    bindings.columnDefinition = valueIfNotBlank(databaseField.columnDefinition());
    bindings.foreignAutoCreate = databaseField.foreignAutoCreate();
    bindings.version = databaseField.version();
    bindings.foreignColumnName = valueIfNotBlank(databaseField.foreignColumnName());
    bindings.readOnly = databaseField.readOnly();

    return bindings;
}
 
开发者ID:koesie10,项目名称:ormlite-processor,代码行数:52,代码来源:FieldBindings.java

示例3: isId

import com.j256.ormlite.field.DatabaseField; //导入方法依赖的package包/类
/**
 * Check if the DatabaseField is an ID field.
 *
 * @param databaseField the annotation to check
 * @return true if id() or generatedId() are true
 */
public static boolean isId(DatabaseField databaseField) {
	return databaseField.id() || databaseField.generatedId();
}
 
开发者ID:ByteWelder,项目名称:Poetry,代码行数:10,代码来源:OrmliteReflection.java


注:本文中的com.j256.ormlite.field.DatabaseField.generatedId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。