org.hibernate.tool.schema.internal.StandardUniqueKeyExporter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
Hibernate's core ORM functionality
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.tool.schema.internal;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.dialect.Dialect;
import org.hibernate.mapping.Constraint;
import org.hibernate.mapping.UniqueKey;
import org.hibernate.tool.schema.spi.Exporter;
/**
* Unique constraint Exporter. Note that it's parameterized for Constraint, rather than UniqueKey. This is
* to allow Dialects to decide whether or not to create unique constraints for unique indexes.
*
* @author Brett Meyer
*/
public class StandardUniqueKeyExporter implements Exporter {
private final Dialect dialect;
public StandardUniqueKeyExporter(Dialect dialect) {
this.dialect = dialect;
}
@Override
public String[] getSqlCreateStrings(Constraint constraint, Metadata metadata,
SqlStringGenerationContext context) {
return new String[] {
dialect.getUniqueDelegate().getAlterTableToAddUniqueKeyCommand(
(UniqueKey) constraint,
metadata,
context
)
};
}
@Override
public String[] getSqlDropStrings(Constraint constraint, Metadata metadata,
SqlStringGenerationContext context) {
return new String[] {
dialect.getUniqueDelegate().getAlterTableToDropUniqueKeyCommand(
(UniqueKey) constraint,
metadata,
context
)
};
}
}