use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class LegacySequenceExportTest 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();
assertEquals(0, metadata.getDatabase().getAuxiliaryDatabaseObjects().size());
int count = 0;
for (Namespace namespace : metadata.getDatabase().getNamespaces()) {
for (Sequence sequence : namespace.getSequences()) {
count++;
}
}
assertEquals(1, count);
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class SequenceExportTest method testMultipleUsesOfDefaultSequenceName.
@Test
@TestForIssue(jiraKey = "HHH-9936")
public void testMultipleUsesOfDefaultSequenceName() {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(Entity1.class).addAnnotatedClass(Entity2.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 DisabledForeignKeyTest method basicTests.
@Test
@TestForIssue(jiraKey = "HHH-9704")
public void basicTests() {
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();
new SchemaExport().execute(EnumSet.of(TargetType.STDOUT), SchemaExport.Action.CREATE, metadata);
int fkCount = 0;
for (Table table : metadata.collectTableMappings()) {
for (Map.Entry<ForeignKeyKey, ForeignKey> entry : table.getForeignKeys().entrySet()) {
assertFalse("Creation for ForeignKey [" + entry.getKey() + "] was not disabled", entry.getValue().isCreationEnabled());
fkCount++;
}
}
// ultimately I want to actually create the ForeignKet reference, but simply disable its creation
// via ForeignKet#disableCreation()
assertEquals("Was expecting 4 FKs", 0, fkCount);
} finally {
StandardServiceRegistryBuilder.destroy(standardRegistry);
}
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class InheritedAttributeOverridingTest method testInheritedAttributeOverridingMappedsuperclass.
@Test
@TestForIssue(jiraKey = "HHH-9485")
public void testInheritedAttributeOverridingMappedsuperclass() {
Metadata metadata = new MetadataSources(standardServiceRegistry).addAnnotatedClass(A.class).addAnnotatedClass(B.class).buildMetadata();
((MetadataImplementor) metadata).validate();
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class AttributeConverterTest method testBasicOrmXmlConverterApplication.
@Test
@TestForIssue(jiraKey = "HHH-8462")
public void testBasicOrmXmlConverterApplication() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(Tester.class).addURL(ConfigHelper.findAsResource("org/hibernate/test/converter/orm.xml")).getMetadataBuilder().build();
PersistentClass tester = metadata.getEntityBinding(Tester.class.getName());
Property nameProp = tester.getProperty("name");
SimpleValue nameValue = (SimpleValue) nameProp.getValue();
Type type = nameValue.getType();
assertNotNull(type);
if (!AttributeConverterTypeAdapter.class.isInstance(type)) {
fail("AttributeConverter not applied");
}
AttributeConverterTypeAdapter basicType = assertTyping(AttributeConverterTypeAdapter.class, type);
assertSame(StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor());
assertEquals(Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType());
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
Aggregations