Search in sources :

Example 1 with ICollectionMetadata

use of org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata in project jbosstools-hibernate by jbosstools.

the class SessionFactoryFacadeImpl method initializeAllCollectionMetadata.

protected void initializeAllCollectionMetadata() {
    SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getTarget();
    MetamodelImplementor metamodel = sessionFactory.getMetamodel();
    Map<String, CollectionPersister> collectionPersisters = metamodel.collectionPersisters();
    allCollectionMetadata = new HashMap<String, ICollectionMetadata>(collectionPersisters.size());
    for (Entry<String, CollectionPersister> entry : collectionPersisters.entrySet()) {
        allCollectionMetadata.put((String) entry.getKey(), getFacadeFactory().createCollectionMetadata(entry.getValue()));
    }
}
Also used : CollectionPersister(org.hibernate.persister.collection.CollectionPersister) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) MetamodelImplementor(org.hibernate.metamodel.spi.MetamodelImplementor) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor)

Example 2 with ICollectionMetadata

use of org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateCollectionMetadata.

@Test
public void testCreateCollectionMetadata() {
    CollectionMetadata collectionMetadata = (CollectionMetadata) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { CollectionMetadata.class }, new TestInvocationHandler());
    ICollectionMetadata facade = facadeFactory.createCollectionMetadata(collectionMetadata);
    Assert.assertSame(collectionMetadata, ((IFacade) facade).getTarget());
}
Also used : CollectionMetadata(org.hibernate.metadata.CollectionMetadata) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) PersistentClass(org.hibernate.mapping.PersistentClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) Test(org.junit.Test)

Example 3 with ICollectionMetadata

use of org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata in project jbosstools-hibernate by jbosstools.

the class SessionFactoryFacadeTest method testGetAllCollectionMetadata.

@Test
public void testGetAllCollectionMetadata() {
    Configuration configuration = new Configuration();
    SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
    ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
    Assert.assertTrue(sessionFactoryFacade.getAllCollectionMetadata().isEmpty());
    sessionFactory.close();
    configuration.addClass(Foo.class);
    sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
    sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
    Map<String, ICollectionMetadata> allCollectionMetaData = sessionFactoryFacade.getAllCollectionMetadata();
    Assert.assertNotNull(allCollectionMetaData.get("org.jboss.tools.hibernate.runtime.v_5_0.internal.test.Foo.bars"));
}
Also used : ISessionFactory(org.jboss.tools.hibernate.runtime.spi.ISessionFactory) SessionFactory(org.hibernate.SessionFactory) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) Configuration(org.hibernate.cfg.Configuration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) ISessionFactory(org.jboss.tools.hibernate.runtime.spi.ISessionFactory) Test(org.junit.Test)

Example 4 with ICollectionMetadata

use of org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateCollectionMetadata.

@Test
public void testCreateCollectionMetadata() {
    CollectionMetadata collectionMetadata = (CollectionMetadata) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { CollectionMetadata.class }, new TestInvocationHandler());
    ICollectionMetadata facade = facadeFactory.createCollectionMetadata(collectionMetadata);
    Assert.assertSame(collectionMetadata, ((IFacade) facade).getTarget());
}
Also used : CollectionMetadata(org.hibernate.metadata.CollectionMetadata) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) PersistentClass(org.hibernate.mapping.PersistentClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) Test(org.junit.Test)

Example 5 with ICollectionMetadata

use of org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateCollectionMetadata.

@Test
public void testCreateCollectionMetadata() {
    CollectionMetadata collectionMetadata = (CollectionMetadata) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { CollectionMetadata.class }, new TestInvocationHandler());
    ICollectionMetadata facade = facadeFactory.createCollectionMetadata(collectionMetadata);
    Assert.assertSame(collectionMetadata, ((IFacade) facade).getTarget());
}
Also used : CollectionMetadata(org.hibernate.metadata.CollectionMetadata) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) PersistentClass(org.hibernate.mapping.PersistentClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) Test(org.junit.Test)

Aggregations

ICollectionMetadata (org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata)18 Test (org.junit.Test)16 SessionFactory (org.hibernate.SessionFactory)8 Configuration (org.hibernate.cfg.Configuration)8 PersistentClass (org.hibernate.mapping.PersistentClass)8 RootClass (org.hibernate.mapping.RootClass)8 CollectionMetadata (org.hibernate.metadata.CollectionMetadata)8 POJOClass (org.hibernate.tool.hbm2x.pojo.POJOClass)8 IPOJOClass (org.jboss.tools.hibernate.runtime.spi.IPOJOClass)8 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)8 ISessionFactory (org.jboss.tools.hibernate.runtime.spi.ISessionFactory)8 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)5 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)2 MetamodelImplementor (org.hibernate.metamodel.spi.MetamodelImplementor)2 CollectionPersister (org.hibernate.persister.collection.CollectionPersister)2 ServiceRegistry (org.hibernate.service.ServiceRegistry)1 ServiceRegistryBuilder (org.hibernate.service.ServiceRegistryBuilder)1