本文整理匯總了Java中com.j256.ormlite.table.DatabaseTable類的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseTable類的具體用法?Java DatabaseTable怎麽用?Java DatabaseTable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DatabaseTable類屬於com.j256.ormlite.table包,在下文中一共展示了DatabaseTable類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTableName
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
/**
* Get the SQLite table name for an OrmLite model.
*
* @param annotationRetriever the annotation retriever that caches the annotations
* @param modelClass an OrmLite model class annotated with {@link DatabaseTable}
* @return the SQLite table name
*/
public static String getTableName(AnnotationRetriever annotationRetriever, Class<?> modelClass) {
DatabaseTable table_annotation = annotationRetriever.getAnnotation(modelClass, DatabaseTable.class);
if (table_annotation == null) {
throw new RuntimeException("DatabaseTable annotation not found for " + modelClass.getName());
}
return getTableName(modelClass, table_annotation);
}
示例2: extractTableName
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
/**
* 獲取表名
*
* @param clazz 表的實體bean
* @param <T>
* @return
*/
public static <T> String extractTableName(Class<T> clazz) {
DatabaseTable databaseTable = clazz.getAnnotation(DatabaseTable.class);
String name;
if (databaseTable != null && !Check.isEmpty(databaseTable.tableName())) {
name = databaseTable.tableName();
} else {
name =new JavaxPersistenceImpl().getEntityName(clazz);
if (name == null) {
name = clazz.getSimpleName().toLowerCase();
}
}
return name;
}
示例3: extractTableName
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
private static String extractTableName(TypeElement element) {
DatabaseTable databaseTable = element.getAnnotation(DatabaseTable.class);
String name;
if (databaseTable != null && databaseTable.tableName() != null && databaseTable.tableName().length() > 0) {
name = databaseTable.tableName();
} else {
// if the name isn't specified, it is the class name lowercased
name = element.getSimpleName().toString().toLowerCase();
}
return name;
}
示例4: classHasAnnotations
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
private static boolean classHasAnnotations(Class<?> paramClass)
{
while (paramClass != null)
{
if (paramClass.getAnnotation(DatabaseTable.class) != null)
return true;
Field[] arrayOfField;
try
{
arrayOfField = paramClass.getDeclaredFields();
}
catch (Throwable localThrowable1)
{
System.err.println("Could not load get delcared fields from: " + paramClass);
System.err.println(" " + localThrowable1);
return false;
}
int i = arrayOfField.length;
for (int j = 0; j < i; j++)
{
Field localField = arrayOfField[j];
if ((localField.getAnnotation(DatabaseField.class) != null) || (localField.getAnnotation(ForeignCollectionField.class) != null))
return true;
}
try
{
paramClass = paramClass.getSuperclass();
}
catch (Throwable localThrowable2)
{
System.err.println("Could not get super class for: " + paramClass);
System.err.println(" " + localThrowable2);
return false;
}
}
return false;
}
示例5: getSupportedAnnotationTypes
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
@Override
public Set<String> getSupportedAnnotationTypes() {
Set<String> annotations = new LinkedHashSet<String>();
annotations.add(DatabaseTable.class.getCanonicalName());
return annotations;
}
示例6: getDatabaseTable
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
private <T extends DbObject<T>> String getDatabaseTable(Class<T> clazz) {
DatabaseTable databaseTable = clazz.getAnnotation(DatabaseTable.class);
return databaseTable == null ? clazz.getSimpleName().toLowerCase() : databaseTable.tableName();
}
示例7: getLastServerTimestamp
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
private <T extends Entity> long getLastServerTimestamp(Class<T> clazz) throws SQLException {
String tableName = clazz.getAnnotation(DatabaseTable.class).tableName();
if(tableName.isEmpty())
tableName = clazz.getSimpleName().toLowerCase();
return mPersistContext.getEntityDao(clazz).queryRawValue("select ifnull(max(last_modified), 0) from " + tableName);
}
示例8: persistArrayOfBaseTypes
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
private List<Object> persistArrayOfBaseTypes(Class<?> modelClass, JSONArray jsonArray, ForeignCollectionFieldSingleTarget singleTargetField) throws JSONException {
DatabaseTable table_annotation = modelClass.getAnnotation(DatabaseTable.class);
if (table_annotation == null) {
throw new RuntimeException("DatabaseTable annotation not found for " + modelClass.getName());
}
String table_name = OrmliteReflection.getTableName(modelClass, table_annotation);
List<Object> results = new ArrayList<>(jsonArray.length());
for (int i = 0; i < jsonArray.length(); i++) {
Object value_object = jsonArray.get(i);
ContentValues content_values = new ContentValues();
content_values.put(singleTargetField.targetField(), value_object.toString());
long inserted_id = database.insert("'" + table_name + "'", singleTargetField.targetField(), content_values);
if (inserted_id == -1) {
throw new SQLiteException("failed to insert " + modelClass.getName());
}
results.add(inserted_id);
}
return results;
}
示例9: propertyInclusion
import com.j256.ormlite.table.DatabaseTable; //導入依賴的package包/類
@Override
public void propertyInclusion(JDefinedClass clazz, JsonNode schema) {
clazz.annotate(DatabaseTable.class).param("tableName", schema.get("table").asText());
}