Search in sources :

Example 36 with Metadata

use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.

the class TestAutoFlushBeforeQueryExecution 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.PRE_UPDATE).appendListener(InitializingPreUpdateEventListener.INSTANCE);
        }

        @Override
        public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
        }
    });
}
Also used : SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Metadata(org.hibernate.boot.Metadata) Integrator(org.hibernate.integrator.spi.Integrator) SessionFactoryServiceRegistry(org.hibernate.service.spi.SessionFactoryServiceRegistry) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry)

Example 37 with Metadata

use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.

the class CollectionPkTest method verifyPkNameUsed.

private void verifyPkNameUsed(String mappingResource, String expectedName) {
    final Metadata metadata = new MetadataSources(ssr).addResource(mappingResource).buildMetadata();
    final JournalingSchemaToolingTarget target = new JournalingSchemaToolingTarget();
    new SchemaCreatorImpl(ssr).doCreation(metadata, false, target);
    assertTrue("Expected foreign-key name [" + expectedName + "] not seen in schema creation output", target.containedText(expectedName));
}
Also used : SchemaCreatorImpl(org.hibernate.tool.schema.internal.SchemaCreatorImpl) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) JournalingSchemaToolingTarget(org.hibernate.test.hbm.index.JournalingSchemaToolingTarget)

Example 38 with Metadata

use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.

the class ExtendsTest method testAllSeparateInOne.

@Test
public void testAllSeparateInOne() {
    Metadata metadata = new MetadataSources(serviceRegistry).addResource(getBaseForMappings() + "extendshbm/allseparateinone.hbm.xml").buildMetadata();
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Customer"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Person"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Employee"));
}
Also used : Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Test(org.junit.Test)

Example 39 with Metadata

use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.

the class ExtendsTest method testOutOfOrder.

@Test
public void testOutOfOrder() {
    Metadata metadata = new MetadataSources(serviceRegistry).addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml").addResource(getBaseForMappings() + "extendshbm/Person.hbm.xml").addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml").buildMetadata();
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Customer"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Person"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Employee"));
}
Also used : Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Test(org.junit.Test)

Example 40 with Metadata

use of org.hibernate.boot.Metadata in project hibernate-orm by hibernate.

the class ExtendsTest method testAllInOne.

@Test
public void testAllInOne() {
    Metadata metadata = new MetadataSources(serviceRegistry).addResource(getBaseForMappings() + "extendshbm/allinone.hbm.xml").buildMetadata();
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Customer"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Person"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Employee"));
}
Also used : Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Test(org.junit.Test)

Aggregations

Metadata (org.hibernate.boot.Metadata)99 MetadataSources (org.hibernate.boot.MetadataSources)88 Test (org.junit.Test)73 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)46 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)41 PersistentClass (org.hibernate.mapping.PersistentClass)29 TestForIssue (org.hibernate.testing.TestForIssue)24 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)12 Property (org.hibernate.mapping.Property)11 SchemaCreatorImpl (org.hibernate.tool.schema.internal.SchemaCreatorImpl)11 Collection (org.hibernate.mapping.Collection)10 RootClass (org.hibernate.mapping.RootClass)10 Map (java.util.Map)9 HashMap (java.util.HashMap)8 SessionFactory (org.hibernate.SessionFactory)8 Session (org.hibernate.Session)7 Integrator (org.hibernate.integrator.spi.Integrator)7 SessionFactoryServiceRegistry (org.hibernate.service.spi.SessionFactoryServiceRegistry)7 ServiceRegistry (org.hibernate.service.ServiceRegistry)6 Properties (java.util.Properties)5