use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class LegacyPostCommitListenerTest method prepareBootstrapRegistryBuilder.
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapRegistryBuilder(builder);
builder.applyIntegrator(new Integrator() {
@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
integrate(serviceRegistry);
}
private void integrate(SessionFactoryServiceRegistry serviceRegistry) {
serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_DELETE).appendListener(postCommitDeleteEventListener);
serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_UPDATE).appendListener(postCommitUpdateEventListener);
serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_INSERT).appendListener(postCommitInsertEventListener);
}
@Override
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
}
});
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class PostCommitListenerTest method prepareBootstrapRegistryBuilder.
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapRegistryBuilder(builder);
builder.applyIntegrator(new Integrator() {
@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
integrate(serviceRegistry);
}
private void integrate(SessionFactoryServiceRegistry serviceRegistry) {
serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_DELETE).appendListener(postCommitDeleteEventListener);
serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_UPDATE).appendListener(postCommitUpdateEventListener);
serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_INSERT).appendListener(postCommitInsertEventListener);
}
@Override
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
}
});
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class ExtendsTest method testMissingSuper.
@Test
public void testMissingSuper() {
try {
Metadata metadata = new MetadataSources(serviceRegistry).addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml").addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml").buildMetadata();
fail("Should not be able to build sessionFactory without a Person");
} catch (HibernateException e) {
}
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class QueryReturnTest method testQueryReturn.
@Test
public void testQueryReturn() {
StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder().applySetting("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
StandardServiceRegistry standardServiceRegistry = serviceRegistryBuilder.build();
MetadataSources metadataSources = new MetadataSources(standardServiceRegistry);
try {
metadataSources.addInputStream(new ReaderInputStream(new StringReader(QUERY_RETURN_HBM_XML)));
Metadata metadata = metadataSources.buildMetadata();
NamedSQLQueryDefinition myQuery = metadata.getNamedNativeQueryDefinition("myQuery");
Assert.assertNotNull(myQuery);
NativeSQLQueryReturn[] myQueryReturns = myQuery.getQueryReturns();
Assert.assertNotNull(myQueryReturns);
Assert.assertEquals(1, myQueryReturns.length);
Assert.assertTrue(NativeSQLQueryRootReturn.class.isInstance(myQueryReturns[0]));
NativeSQLQueryRootReturn myQueryRootReturn = (NativeSQLQueryRootReturn) myQueryReturns[0];
Assert.assertEquals("e", myQueryRootReturn.getAlias());
Assert.assertEquals("org.hibernate.test.hbm.query.QueryReturnTest$Bar", myQueryRootReturn.getReturnEntityName());
} finally {
if (standardServiceRegistry instanceof StandardServiceRegistryImpl) {
((StandardServiceRegistryImpl) standardServiceRegistry).destroy();
}
}
}
use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.
the class UniqueDelegateTest method testUniqueDelegateConsulted.
@Test
@TestForIssue(jiraKey = "HHH-10203")
public void testUniqueDelegateConsulted() {
final Metadata metadata = new MetadataSources(ssr).addResource("org/hibernate/test/hbm/uk/person_unique.hbm.xml").buildMetadata();
final JournalingSchemaToolingTarget target = new JournalingSchemaToolingTarget();
new SchemaCreatorImpl(ssr).doCreation(metadata, false, target);
assertThat(getAlterTableToAddUniqueKeyCommandCallCount, equalTo(1));
assertThat(getColumnDefinitionUniquenessFragmentCallCount, equalTo(1));
assertThat(getTableCreationUniqueConstraintsFragmentCallCount, equalTo(1));
new SchemaDropperImpl(ssr).doDrop(metadata, false, target);
// unique keys are not dropped explicitly
assertThat(getAlterTableToAddUniqueKeyCommandCallCount, equalTo(1));
assertThat(getColumnDefinitionUniquenessFragmentCallCount, equalTo(1));
assertThat(getTableCreationUniqueConstraintsFragmentCallCount, equalTo(1));
}
Aggregations