com.j256.ormlite.table.DatabaseTable Java Examples
The following examples show how to use
com.j256.ormlite.table.DatabaseTable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatabaseAction.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
public List<String> getTableNames(List<String> tableClassNames) { ClassLoader cl = ComponentManager.getComponentInstallerClassLoader(); if (null == tableClassNames || tableClassNames.isEmpty()) { return null; } List<String> tableNames = new ArrayList<String>(); try { for (int i = 0; i < tableClassNames.size(); i++) { String tableClassName = tableClassNames.get(i); Class tableClass = null; if (cl != null) { tableClass = Class.forName(tableClassName, true, cl); } else { tableClass = Class.forName(tableClassName); } DatabaseTable tableAnnotation = (DatabaseTable) tableClass.getAnnotation(DatabaseTable.class); tableNames.add(tableAnnotation.tableName()); } } catch (Throwable t) { _logger.error("Error extracting table names", t); throw new RuntimeException("Error extracting table names", t); } return tableNames; }
Example #2
Source File: DatabaseUtil.java From AndroidBase with Apache License 2.0 | 5 votes |
/** * 获取表名 * * @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; }
Example #3
Source File: OrmliteReflection.java From poetry with Apache License 2.0 | 5 votes |
/** * 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); }
Example #4
Source File: JsonPersister.java From poetry with Apache License 2.0 | 5 votes |
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 = mDatabase.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; }
Example #5
Source File: TableFactory.java From entando-core with GNU Lesser General Public License v3.0 | 4 votes |
public static String getTableName(Class tableClass) { DatabaseTable tableAnnotation = (DatabaseTable) tableClass.getAnnotation(DatabaseTable.class); return tableAnnotation.tableName(); }
Example #6
Source File: OrmliteReflection.java From poetry with Apache License 2.0 | 2 votes |
/** * Get the SQLite table name for an OrmLite model. * * @param modelClass an OrmLite model class annotated with {@link DatabaseTable} * @param tableAnnotation the annotation to process * @return the SQLite table name */ public static String getTableName(Class<?> modelClass, DatabaseTable tableAnnotation) { return !tableAnnotation.tableName().isEmpty() ? tableAnnotation.tableName() : modelClass.getSimpleName(); }