in grails-datastore-gorm-hibernate/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java [1723:1793]
protected void bindRootPersistentClassCommonValues(HibernatePersistentEntity domainClass,
RootClass root, InFlightMetadataCollector mappings, String sessionFactoryBeanName) {
// get the schema and catalog names from the configuration
Mapping m = getMapping(domainClass.getJavaClass());
String schema = getSchemaName(mappings);
String catalog = getCatalogName(mappings);
if (m != null) {
configureDerivedProperties(domainClass, m);
CacheConfig cc = m.getCache();
if (cc != null && cc.getEnabled()) {
root.setCacheConcurrencyStrategy(cc.getUsage());
root.setCached(true);
if ("read-only".equals(cc.getUsage())) {
root.setMutable(false);
}
root.setLazyPropertiesCacheable(!"non-lazy".equals(cc.getInclude()));
}
Integer bs = m.getBatchSize();
if (bs != null) {
root.setBatchSize(bs);
}
if (m.getDynamicUpdate()) {
root.setDynamicUpdate(true);
}
if (m.getDynamicInsert()) {
root.setDynamicInsert(true);
}
}
final boolean hasTableDefinition = m != null && m.getTable() != null;
if (hasTableDefinition && m.getTable().getSchema() != null) {
schema = m.getTable().getSchema();
}
if (hasTableDefinition && m.getTable().getCatalog() != null) {
catalog = m.getTable().getCatalog();
}
final boolean isAbstract = m != null && !m.getTablePerHierarchy() && m.isTablePerConcreteClass() && root.isAbstract();
// create the table
Table table = mappings.addTable(schema, catalog,
getTableName(domainClass, sessionFactoryBeanName),
null, isAbstract);
root.setTable(table);
if (LOG.isDebugEnabled()) {
LOG.debug("[GrailsDomainBinder] Mapping Grails domain class: " + domainClass.getName() + " -> " + root.getTable().getName());
}
bindIdentity(domainClass, root, mappings, m, sessionFactoryBeanName);
if (m == null) {
bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
}
else {
if (m.getVersioned()) {
bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
}
else {
root.setOptimisticLockStyle(OptimisticLockStyle.NONE);
}
}
root.createPrimaryKey();
createClassProperties(domainClass, root, mappings, sessionFactoryBeanName);
}