use of org.hibernate.boot.model.relational.SimpleAuxiliaryDatabaseObject in project hibernate-orm by hibernate.
the class AuxiliaryDatabaseObjectBinder method processAuxiliaryDatabaseObject.
/**
* Handling for a {@code <database-object/>} declaration.
*
* @param context Access to information relative to the mapping document containing this binding
* @param auxDbObjectMapping The {@code <database-object/>} binding
*/
public static void processAuxiliaryDatabaseObject(HbmLocalMetadataBuildingContext context, JaxbHbmAuxiliaryDatabaseObjectType auxDbObjectMapping) {
final AuxiliaryDatabaseObject auxDbObject;
if (auxDbObjectMapping.getDefinition() != null) {
final String auxDbObjectImplClass = auxDbObjectMapping.getDefinition().getClazz();
try {
auxDbObject = (AuxiliaryDatabaseObject) context.getBuildingOptions().getServiceRegistry().getService(ClassLoaderService.class).classForName(auxDbObjectImplClass).newInstance();
} catch (ClassLoadingException cle) {
throw cle;
} catch (Exception e) {
throw new org.hibernate.boot.MappingException(String.format("Unable to instantiate custom AuxiliaryDatabaseObject class [%s]", auxDbObjectImplClass), context.getOrigin());
}
} else {
auxDbObject = new SimpleAuxiliaryDatabaseObject(context.getMetadataCollector().getDatabase().getDefaultNamespace(), auxDbObjectMapping.getCreate(), auxDbObjectMapping.getDrop(), null);
}
if (!auxDbObjectMapping.getDialectScope().isEmpty()) {
if (AuxiliaryDatabaseObject.Expandable.class.isInstance(auxDbObject)) {
final AuxiliaryDatabaseObject.Expandable expandable = (AuxiliaryDatabaseObject.Expandable) auxDbObject;
for (JaxbHbmDialectScopeType dialectScopeBinding : auxDbObjectMapping.getDialectScope()) {
expandable.addDialectScope(dialectScopeBinding.getName());
}
} else {
// error? warn?
}
}
context.getMetadataCollector().getDatabase().addAuxiliaryDatabaseObject(auxDbObject);
}
Aggregations