use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class DisabledForeignKeyTest method expandedTests.
@Test
@TestForIssue(jiraKey = "HHH-9704")
public void expandedTests() {
StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder();
StandardServiceRegistry standardRegistry = registryBuilder.build();
try {
final MetadataSources sources = new MetadataSources(standardRegistry);
sources.addAnnotatedClass(ManyToManyOwner.class);
sources.addAnnotatedClass(ManyToManyTarget.class);
final MetadataImplementor metadata = (MetadataImplementor) sources.buildMetadata();
metadata.validate();
// export the schema
new SchemaExport().execute(EnumSet.of(TargetType.DATABASE), SchemaExport.Action.BOTH, metadata);
try {
// update the schema
new SchemaUpdate().execute(EnumSet.of(TargetType.DATABASE), metadata);
} finally {
// drop the schema
new SchemaExport().execute(EnumSet.of(TargetType.DATABASE), SchemaExport.Action.DROP, metadata);
}
} finally {
StandardServiceRegistryBuilder.destroy(standardRegistry);
}
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class SequenceExportTest method testMultipleUsesOfExplicitSequenceName.
@Test
@TestForIssue(jiraKey = "HHH-9936")
public void testMultipleUsesOfExplicitSequenceName() {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(Entity3.class).addAnnotatedClass(Entity4.class).buildMetadata();
metadata.validate();
int namespaceCount = 0;
int sequenceCount = 0;
for (Namespace namespace : metadata.getDatabase().getNamespaces()) {
namespaceCount++;
for (Sequence sequence : namespace.getSequences()) {
sequenceCount++;
}
}
assertEquals(1, namespaceCount);
assertEquals(1, sequenceCount);
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class ValueVisitorTest method testProperCallbacks.
@Test
public void testProperCallbacks() {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();
final Table tbl = new Table();
final RootClass rootClass = new RootClass(metadataBuildingContext);
ValueVisitor vv = new ValueVisitorValidator();
new Any(metadata, tbl).accept(vv);
new Array(metadata, rootClass).accept(vv);
new Bag(metadata, rootClass).accept(vv);
new Component(metadata, rootClass).accept(vv);
new DependantValue(metadata, tbl, null).accept(vv);
new IdentifierBag(metadata, rootClass).accept(vv);
new List(metadata, rootClass).accept(vv);
new ManyToOne(metadata, tbl).accept(vv);
new Map(metadata, rootClass).accept(vv);
new OneToMany(metadata, rootClass).accept(vv);
new OneToOne(metadata, tbl, rootClass).accept(vv);
new PrimitiveArray(metadata, rootClass).accept(vv);
new Set(metadata, rootClass).accept(vv);
new SimpleValue(metadata).accept(vv);
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class Tests method testJpaJoinColumnPhysicalNaming.
@Test
@TestForIssue(jiraKey = "HHH-9961")
public void testJpaJoinColumnPhysicalNaming() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySettings(Environment.getProperties()).build();
try {
final MetadataSources metadataSources = new MetadataSources(ssr);
metadataSources.addAnnotatedClass(Language.class);
final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
metadataBuilder.applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE);
metadataBuilder.applyPhysicalNamingStrategy(PhysicalNamingStrategyImpl.INSTANCE);
final Metadata metadata = metadataBuilder.build();
((MetadataImplementor) metadata).validate();
final PersistentClass languageBinding = metadata.getEntityBinding(Language.class.getName());
final Property property = languageBinding.getProperty("fallBack");
Iterator itr = property.getValue().getColumnIterator();
assertTrue(itr.hasNext());
final Column column = (Column) itr.next();
assertFalse(itr.hasNext());
assertEquals("C_FALLBACK_ID", column.getName().toUpperCase(Locale.ROOT));
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class SequenceReadingTest method testSequenceReading.
@Test
public void testSequenceReading() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.DIALECT, MyExtendedH2Dialect.class).build();
try {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(MyEntity.class).buildMetadata();
metadata.validate();
try {
// try to update the schema
new SchemaUpdate().execute(EnumSet.of(TargetType.DATABASE), metadata);
} finally {
try {
// clean up
new SchemaExport().drop(EnumSet.of(TargetType.DATABASE), metadata);
} catch (Exception ignore) {
}
}
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
Aggregations