use of org.hibernate.boot.model.relational.Sequence in project hibernate-orm by hibernate.
the class SequenceNamingStrategyTest method verify.
private void verify(Class<?> entityType, String strategy, String expectedName) {
withMetadata(entityType, strategy, (metadata) -> {
final Namespace defaultNamespace = metadata.getDatabase().getDefaultNamespace();
final Sequence sequence = defaultNamespace.locateSequence(Identifier.toIdentifier(expectedName));
assertThat(sequence).isNotNull();
final PersistentClass entityBinding = metadata.getEntityBinding(entityType.getName());
final IdentifierGenerator generator = extractGenerator(entityBinding);
assertThat(generator).isInstanceOf(SequenceStyleGenerator.class);
final SequenceStyleGenerator sequenceStyleGenerator = (SequenceStyleGenerator) generator;
assertThat(sequenceStyleGenerator.getDatabaseStructure()).isInstanceOf(SequenceStructure.class);
final SequenceStructure sequenceStructure = (SequenceStructure) sequenceStyleGenerator.getDatabaseStructure();
assertThat(sequenceStructure.getPhysicalName().getObjectName().getText()).isEqualTo(expectedName);
});
}
use of org.hibernate.boot.model.relational.Sequence 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++;
}
}
assertThat(namespaceCount).isEqualTo(1);
// 1 per entity
assertThat(sequenceCount).isEqualTo(2);
}
use of org.hibernate.boot.model.relational.Sequence 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++;
}
}
assertThat(namespaceCount).isEqualTo(1);
assertThat(sequenceCount).isEqualTo(1);
}
use of org.hibernate.boot.model.relational.Sequence in project hibernate-orm by hibernate.
the class LegacySequenceExportTest 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();
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.model.relational.Sequence 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);
}
Aggregations