Search in sources :

Example 96 with Metadata

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

the class TestCollectionInitializingDuringFlush 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 97 with Metadata

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

the class ClassCommentTest method testClassComment.

@Test
public void testClassComment() {
    StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder().applySetting("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    MetadataSources metadataSources = new MetadataSources(serviceRegistryBuilder.build());
    metadataSources.addInputStream(new ReaderInputStream(new StringReader(CLASS_COMMENT_HBM_XML)));
    Metadata metadata = metadataSources.buildMetadata();
    PersistentClass pc = metadata.getEntityBinding("org.hibernate.test.hbm.Foo");
    Assert.assertNotNull(pc);
    Table table = pc.getTable();
    Assert.assertNotNull(table);
    Assert.assertEquals("This is class 'Foo' with property 'bar'.", table.getComment());
}
Also used : ReaderInputStream(org.hibernate.engine.jdbc.ReaderInputStream) Table(org.hibernate.mapping.Table) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataSources(org.hibernate.boot.MetadataSources) StringReader(java.io.StringReader) Metadata(org.hibernate.boot.Metadata) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 98 with Metadata

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

the class CollectionKeyFkNameTest method verifyFkNameUsed.

private void verifyFkNameUsed(String mappingResource, String expectedName) {
    final Metadata metadata = new MetadataSources(ssr).addResource(mappingResource).buildMetadata();
    final JournalingSchemaToolingTarget target = new JournalingSchemaToolingTarget();
    new SchemaCreatorImpl(ssr).doCreation(metadata, ssr, ssr.getService(ConfigurationService.class).getSettings(), 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 99 with Metadata

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

the class IndexTest method verifyIndexCreated.

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

Example 100 with Metadata

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

the class EagerKeyManyToOneTest 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).prependListeners(EventType.LOAD, new CustomLoadListener());
        }

        @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)

Aggregations

Metadata (org.hibernate.boot.Metadata)148 MetadataSources (org.hibernate.boot.MetadataSources)124 Test (org.junit.Test)103 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)73 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)56 PersistentClass (org.hibernate.mapping.PersistentClass)46 TestForIssue (org.hibernate.testing.TestForIssue)31 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)18 Session (org.hibernate.Session)14 HashMap (java.util.HashMap)13 SchemaCreatorImpl (org.hibernate.tool.schema.internal.SchemaCreatorImpl)13 Property (org.hibernate.mapping.Property)12 RootClass (org.hibernate.mapping.RootClass)12 Map (java.util.Map)11 IdentifierGenerator (org.hibernate.id.IdentifierGenerator)11 SessionFactory (org.hibernate.SessionFactory)10 Collection (org.hibernate.mapping.Collection)10 ServiceRegistryImplementor (org.hibernate.service.spi.ServiceRegistryImplementor)10 ServiceRegistry (org.hibernate.service.ServiceRegistry)8 Before (org.junit.Before)8