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">
|
<class name="Car">
|
||||||
|
|
||||||
<id name="id">
|
<id name="id">
|
||||||
<generator class="org.hibernate.id.MultipleHiLoPerTableGenerator">
|
<generator class="org.hibernate.id".MultipleHiLoPerTableGenerator">
|
||||||
<param name="max_lo">0</param>
|
<param name="max_lo">0</param>
|
||||||
</generator>
|
</generator>
|
||||||
</id>
|
</id>
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.schemavalidation;
|
package org.hibernate.test.schemavalidation;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
@ -16,19 +14,10 @@ import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.schema.SourceType;
|
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.hbm2ddl.Target;
|
||||||
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.testing.FailureExpected;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -39,7 +28,7 @@ import org.junit.Test;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@TestForIssue( jiraKey = "HHH-9693" )
|
@TestForIssue( jiraKey = "HHH-9693" )
|
||||||
public class LongVarcharValidationTest extends BaseUnitTestCase implements ExecutionOptions {
|
public class LongVarcharValidationTest extends BaseUnitTestCase {
|
||||||
private StandardServiceRegistry ssr;
|
private StandardServiceRegistry ssr;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -63,81 +52,16 @@ public class LongVarcharValidationTest extends BaseUnitTestCase implements Execu
|
||||||
|
|
||||||
|
|
||||||
// create the schema
|
// create the schema
|
||||||
createSchema( metadata );
|
new SchemaExport( metadata ).create( Target.EXPORT );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
doValidation( metadata );
|
new SchemaValidator( metadata ).validate();
|
||||||
}
|
}
|
||||||
finally {
|
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
|
@Entity
|
||||||
public static class Translation {
|
public static class Translation {
|
||||||
@Id
|
@Id
|
||||||
|
@ -146,18 +70,4 @@ public class LongVarcharValidationTest extends BaseUnitTestCase implements Execu
|
||||||
String text;
|
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