HHH-6418 : org.hibernate.metamodel.relational.AuxiliaryDatabaseObject extends org.hibernate.mapping.RelationalModel
This commit is contained in:
parent
310c0441bb
commit
ad3b58f5e2
|
@ -24,9 +24,11 @@
|
|||
package org.hibernate.metamodel.relational;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.mapping.AuxiliaryDatabaseObject;
|
||||
|
||||
/**
|
||||
* Convenience base class for {@link org.hibernate.mapping.AuxiliaryDatabaseObject}s.
|
||||
|
@ -38,22 +40,27 @@ import org.hibernate.mapping.AuxiliaryDatabaseObject;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractAuxiliaryDatabaseObject implements AuxiliaryDatabaseObject {
|
||||
// Use a UUID in identifier prefix because this object is not qualified by a schema/catalog
|
||||
// (not sure this matters...)
|
||||
private static final String EXPORT_IDENTIFIER_PREFIX = "auxiliary-object-" + UUID.randomUUID();
|
||||
private static final AtomicInteger counter = new AtomicInteger( 0 );
|
||||
private final String exportIdentifier;
|
||||
private final Set<String> dialectScopes;
|
||||
|
||||
private final HashSet dialectScopes;
|
||||
|
||||
protected AbstractAuxiliaryDatabaseObject() {
|
||||
this.dialectScopes = new HashSet();
|
||||
}
|
||||
|
||||
protected AbstractAuxiliaryDatabaseObject(HashSet dialectScopes) {
|
||||
this.dialectScopes = dialectScopes;
|
||||
protected AbstractAuxiliaryDatabaseObject(Set<String> dialectScopes) {
|
||||
this.dialectScopes = dialectScopes == null ? new HashSet<String>() : dialectScopes;
|
||||
this.exportIdentifier =
|
||||
new StringBuilder( EXPORT_IDENTIFIER_PREFIX )
|
||||
.append( '.' )
|
||||
.append( counter.getAndIncrement() )
|
||||
.toString();
|
||||
}
|
||||
|
||||
public void addDialectScope(String dialectName) {
|
||||
dialectScopes.add( dialectName );
|
||||
}
|
||||
|
||||
public HashSet getDialectScopes() {
|
||||
public Iterable<String> getDialectScopes() {
|
||||
return dialectScopes;
|
||||
}
|
||||
|
||||
|
@ -61,4 +68,9 @@ public abstract class AbstractAuxiliaryDatabaseObject implements AuxiliaryDataba
|
|||
// empty means no scoping
|
||||
return dialectScopes.isEmpty() || dialectScopes.contains( dialect.getClass().getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExportIdentifier() {
|
||||
return exportIdentifier;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ package org.hibernate.metamodel.relational;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.mapping.RelationalModel;
|
||||
|
||||
/**
|
||||
* Auxiliary database objects (i.e., triggers, stored procedures, etc) defined
|
||||
|
@ -35,7 +34,7 @@ import org.hibernate.mapping.RelationalModel;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AuxiliaryDatabaseObject extends RelationalModel, Serializable {
|
||||
public interface AuxiliaryDatabaseObject extends Exportable, Serializable {
|
||||
/**
|
||||
* Does this database object apply to the given dialect?
|
||||
*
|
||||
|
|
|
@ -31,29 +31,24 @@ import org.hibernate.engine.spi.Mapping;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BasicAuxiliaryDatabaseObjectImpl implements AuxiliaryDatabaseObject {
|
||||
public class BasicAuxiliaryDatabaseObjectImpl extends AbstractAuxiliaryDatabaseObject {
|
||||
private final String createString;
|
||||
private final String dropString;
|
||||
private final Set<String> dialectScopes;
|
||||
|
||||
public BasicAuxiliaryDatabaseObjectImpl(String createString, String dropString, Set<String> dialectScopes) {
|
||||
super( dialectScopes );
|
||||
this.createString = createString;
|
||||
this.dropString = dropString;
|
||||
this.dialectScopes = dialectScopes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesToDialect(Dialect dialect) {
|
||||
// empty means no scoping
|
||||
return dialectScopes.isEmpty() || dialectScopes.contains( dialect.getClass().getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO: fix this when HHH-6431 is fixed
|
||||
//@Override
|
||||
public String sqlCreateString(Dialect dialect, Mapping p, String defaultCatalog, String defaultSchema) {
|
||||
return createString;
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO: fix this when HHH-6431 is fixed
|
||||
//@Override
|
||||
public String sqlDropString(Dialect dialect, String defaultCatalog, String defaultSchema) {
|
||||
return dropString;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue