use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class UniqueConstraintUnitTests method testUnNamedConstraints.
@Test
@TestForIssue(jiraKey = "HHH-8026")
public void testUnNamedConstraints() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
final Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(UniqueNoNameA.class).addAnnotatedClass(UniqueNoNameB.class).buildMetadata();
org.hibernate.mapping.Table tableA = null;
org.hibernate.mapping.Table tableB = null;
for (org.hibernate.mapping.Table table : metadata.collectTableMappings()) {
if (table.getName().equals("UniqueNoNameA")) {
tableA = table;
} else if (table.getName().equals("UniqueNoNameB")) {
tableB = table;
}
}
assertTrue("Could not find the expected tables.", tableA != null && tableB != null);
assertFalse(tableA.getUniqueKeyIterator().next().getName().equals(tableB.getUniqueKeyIterator().next().getName()));
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class NonRootEntityWithCacheAnnotationTest method testCacheOnNonRootEntity.
@Test
public void testCacheOnNonRootEntity() {
Map settings = new HashMap();
settings.put(Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName());
settings.put(AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE);
ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder().applySettings(settings).build();
Triggerable triggerable = logInspection.watchForLogMessages("HHH000482");
Metadata metadata = new MetadataSources(serviceRegistry).addAnnotatedClass(ABase.class).addAnnotatedClass(AEntity.class).buildMetadata();
assertTrue(triggerable.wasTriggered());
assertNull((metadata.getEntityBinding(AEntity.class.getName())).getCacheConcurrencyStrategy());
serviceRegistry.destroy();
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class NonRootEntityWithCacheableAnnotationTest method testCacheableOnNonRootEntity.
@Test
public void testCacheableOnNonRootEntity() {
Map settings = new HashMap();
settings.put(Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName());
settings.put(AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, "read-write");
settings.put(AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE);
ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder().applySettings(settings).build();
Triggerable triggerable = logInspection.watchForLogMessages("HHH000482");
Metadata metadata = new MetadataSources(serviceRegistry).addAnnotatedClass(ABase.class).addAnnotatedClass(AEntity.class).buildMetadata();
assertTrue(triggerable.wasTriggered());
assertNull((metadata.getEntityBinding(AEntity.class.getName())).getCacheConcurrencyStrategy());
serviceRegistry.destroy();
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class MultipleBagFetchTest method testEntityWithMultipleJoinFetchedBags.
@Test
public void testEntityWithMultipleJoinFetchedBags() {
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().build();
Metadata metadata = new MetadataSources(standardRegistry).addAnnotatedClass(Post.class).addAnnotatedClass(PostComment.class).addAnnotatedClass(Tag.class).getMetadataBuilder().build();
try {
metadata.buildSessionFactory();
fail("MultipleBagFetchException should have been thrown.");
} catch (MultipleBagFetchException expected) {
}
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class AnnotationBinderTest method testInvalidPrimaryKeyJoinColumnAnnotationMessageContainsClassName.
@Test
public void testInvalidPrimaryKeyJoinColumnAnnotationMessageContainsClassName() throws Exception {
Triggerable triggerable = logInspection.watchForLogMessages("HHH000137");
StandardServiceRegistryBuilder srb = new StandardServiceRegistryBuilder();
Metadata metadata = new MetadataSources(srb.build()).addAnnotatedClass(InvalidPrimaryKeyJoinColumnAnnotationEntity.class).buildMetadata();
assertTrue("Expected warning HHH00137 but it wasn't triggered", triggerable.wasTriggered());
assertTrue("Expected invalid class name in warning HHH00137 message but it does not apper to be present; got " + triggerable.triggerMessage(), triggerable.triggerMessage().matches(".*\\b\\Q" + InvalidPrimaryKeyJoinColumnAnnotationEntity.class.getName() + "\\E\\b.*"));
}
Aggregations