HHH-9693 - H2 : Hibernate cannot validate it's own created schema
This commit is contained in:
parent
74ae003d43
commit
dafbd90ac2
|
@ -21,7 +21,7 @@
|
|||
<class name="Car">
|
||||
|
||||
<id name="id">
|
||||
<generator class="org.hibernate.id.MultipleHiLoPerTableGenerator">
|
||||
<generator class="org.hibernate.id".MultipleHiLoPerTableGenerator">
|
||||
<param name="max_lo">0</param>
|
||||
</generator>
|
||||
</id>
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.test.schemavalidation;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Map;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
|
@ -16,19 +14,10 @@ import org.hibernate.boot.MetadataSources;
|
|||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.tool.schema.SourceType;
|
||||
import org.hibernate.tool.schema.TargetType;
|
||||
import org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl;
|
||||
import org.hibernate.tool.schema.spi.ExceptionHandler;
|
||||
import org.hibernate.tool.schema.spi.ExecutionOptions;
|
||||
import org.hibernate.tool.schema.spi.SchemaManagementTool;
|
||||
import org.hibernate.tool.schema.spi.ScriptSourceInput;
|
||||
import org.hibernate.tool.schema.spi.ScriptTargetOutput;
|
||||
import org.hibernate.tool.schema.spi.SourceDescriptor;
|
||||
import org.hibernate.tool.schema.spi.TargetDescriptor;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
||||
import org.hibernate.tool.hbm2ddl.Target;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.After;
|
||||
|
@ -39,7 +28,7 @@ import org.junit.Test;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-9693" )
|
||||
public class LongVarcharValidationTest extends BaseUnitTestCase implements ExecutionOptions {
|
||||
public class LongVarcharValidationTest extends BaseUnitTestCase {
|
||||
private StandardServiceRegistry ssr;
|
||||
|
||||
@Before
|
||||
|
@ -63,81 +52,16 @@ public class LongVarcharValidationTest extends BaseUnitTestCase implements Execu
|
|||
|
||||
|
||||
// create the schema
|
||||
createSchema( metadata );
|
||||
new SchemaExport( metadata ).create( Target.EXPORT );
|
||||
|
||||
try {
|
||||
doValidation( metadata );
|
||||
new SchemaValidator( metadata ).validate();
|
||||
}
|
||||
finally {
|
||||
dropSchema( metadata );
|
||||
new SchemaExport( metadata ).drop( Target.EXPORT );
|
||||
}
|
||||
}
|
||||
|
||||
private void doValidation(MetadataImplementor metadata) {
|
||||
ssr.getService( SchemaManagementTool.class ).getSchemaValidator( null ).doValidation(
|
||||
metadata,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
private void createSchema(MetadataImplementor metadata) {
|
||||
ssr.getService( SchemaManagementTool.class ).getSchemaCreator( null ).doCreation(
|
||||
metadata,
|
||||
this,
|
||||
new SourceDescriptor() {
|
||||
@Override
|
||||
public SourceType getSourceType() {
|
||||
return SourceType.METADATA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptSourceInput getScriptSourceInput() {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
new TargetDescriptor() {
|
||||
@Override
|
||||
public EnumSet<TargetType> getTargetTypes() {
|
||||
return EnumSet.of( TargetType.DATABASE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptTargetOutput getScriptTargetOutput() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void dropSchema(MetadataImplementor metadata) {
|
||||
ssr.getService( SchemaManagementTool.class ).getSchemaDropper( null ).doDrop(
|
||||
metadata,
|
||||
this,
|
||||
new SourceDescriptor() {
|
||||
@Override
|
||||
public SourceType getSourceType() {
|
||||
return SourceType.METADATA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptSourceInput getScriptSourceInput() {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
new TargetDescriptor() {
|
||||
@Override
|
||||
public EnumSet<TargetType> getTargetTypes() {
|
||||
return EnumSet.of( TargetType.DATABASE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptTargetOutput getScriptTargetOutput() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Entity
|
||||
public static class Translation {
|
||||
@Id
|
||||
|
@ -146,18 +70,4 @@ public class LongVarcharValidationTest extends BaseUnitTestCase implements Execu
|
|||
String text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getConfigurationValues() {
|
||||
return ssr.getService( ConfigurationService.class ).getSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldManageNamespaces() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExceptionHandler getExceptionHandler() {
|
||||
return ExceptionHandlerLoggedImpl.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue