use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class CommentGenerationTest method testSchemaUpdateScriptGeneration.
@Test
public void testSchemaUpdateScriptGeneration() throws Exception {
final String resource = "org/hibernate/test/schemaupdate/CommentGeneration.hbm.xml";
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(Environment.HBM2DDL_AUTO, "none").applySetting(Environment.DIALECT, SupportCommentDialect.class.getName()).build();
try {
File output = File.createTempFile("update_script", ".sql");
output.deleteOnExit();
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addResource(resource).buildMetadata();
metadata.validate();
new SchemaUpdate().setHaltOnError(true).setOutputFile(output.getAbsolutePath()).setDelimiter(";").setFormat(true).execute(EnumSet.of(TargetType.SCRIPT), metadata);
String fileContent = new String(Files.readAllBytes(output.toPath()));
assertThat(fileContent.contains("comment on column version.description "), is(true));
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class QuotedTableNameWithForeignKeysSchemaUpdateTest method setUp.
@Before
public void setUp() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addResource("org/hibernate/test/schemaupdate/UserGroup.hbm.xml").buildMetadata();
metadata.validate();
new SchemaUpdate().execute(EnumSet.of(TargetType.DATABASE), metadata);
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class QuotedTableNameWithForeignKeysSchemaUpdateTest method testGeneratingUpdateScript.
@Test
public void testGeneratingUpdateScript() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addResource("org/hibernate/test/schemaupdate/UserGroup.hbm.xml").buildMetadata();
new SchemaUpdate().execute(EnumSet.of(TargetType.STDOUT), metadata);
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class QuotedTableNameWithForeignKeysSchemaUpdateTest method tearDown.
@After
public void tearDown() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addResource("org/hibernate/test/schemaupdate/UserGroup.hbm.xml").buildMetadata();
new SchemaExport().drop(EnumSet.of(TargetType.STDOUT, TargetType.DATABASE), metadata);
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.
the class SchemaExportTest method setUp.
@Before
public void setUp() {
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(Environment.getProperties());
metadata = (MetadataImplementor) new MetadataSources(serviceRegistry).addResource("org/hibernate/test/schemaupdate/mapping.hbm.xml").buildMetadata();
metadata.validate();
new SchemaExport().drop(EnumSet.of(TargetType.DATABASE, TargetType.STDOUT), metadata);
}
Aggregations