當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。