use of org.h2.jaqu.Table.JQSchema in project h2database by h2database.
the class TableDefinition method mapObject.
void mapObject(Object obj) {
fieldMap.clear();
initObject(obj, fieldMap);
if (clazz.isAnnotationPresent(JQSchema.class)) {
JQSchema schemaAnnotation = clazz.getAnnotation(JQSchema.class);
// setup schema name mapping, if properly annotated
if (!StringUtils.isNullOrEmpty(schemaAnnotation.name())) {
schemaName = schemaAnnotation.name();
}
}
if (clazz.isAnnotationPresent(JQTable.class)) {
JQTable tableAnnotation = clazz.getAnnotation(JQTable.class);
// setup table name mapping, if properly annotated
if (!StringUtils.isNullOrEmpty(tableAnnotation.name())) {
tableName = tableAnnotation.name();
}
// allow control over createTableIfRequired()
createTableIfRequired = tableAnnotation.createIfRequired();
// model version
if (tableAnnotation.version() > 0) {
tableVersion = tableAnnotation.version();
}
// setup the primary index, if properly annotated
List<String> primaryKey = getColumns(tableAnnotation.primaryKey());
if (primaryKey != null) {
setPrimaryKey(primaryKey);
}
}
if (clazz.isAnnotationPresent(JQIndex.class)) {
JQIndex indexAnnotation = clazz.getAnnotation(JQIndex.class);
// setup the indexes, if properly annotated
addIndexes(IndexType.STANDARD, indexAnnotation.standard());
addIndexes(IndexType.UNIQUE, indexAnnotation.unique());
addIndexes(IndexType.HASH, indexAnnotation.hash());
addIndexes(IndexType.UNIQUE_HASH, indexAnnotation.uniqueHash());
}
}