Search in sources :

Example 1 with IClassMetadata

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

the class SessionFactoryFacadeTest method testGetAllClassMetadata.

@Test
public void testGetAllClassMetadata() throws Exception {
    Configuration configuration = new Configuration();
    SessionFactory sessionFactory = configuration.buildSessionFactory();
    ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
    Assert.assertTrue(sessionFactoryFacade.getAllClassMetadata().isEmpty());
    sessionFactory.close();
    configuration.addClass(Foo.class);
    sessionFactory = configuration.buildSessionFactory();
    sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
    Map<String, IClassMetadata> allClassMetaData = sessionFactoryFacade.getAllClassMetadata();
    Assert.assertNotNull(allClassMetaData.get("org.jboss.tools.hibernate.runtime.v_3_6.internal.test.Foo"));
}
Also used : ISessionFactory(org.jboss.tools.hibernate.runtime.spi.ISessionFactory) SessionFactory(org.hibernate.SessionFactory) Configuration(org.hibernate.cfg.Configuration) ISessionFactory(org.jboss.tools.hibernate.runtime.spi.ISessionFactory) IClassMetadata(org.jboss.tools.hibernate.runtime.spi.IClassMetadata) Test(org.junit.Test)

Example 2 with IClassMetadata

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

the class FacadeFactoryTest method testCreateClassMetadata.

@Test
public void testCreateClassMetadata() {
    ClassMetadata classMetadata = (ClassMetadata) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { ClassMetadata.class }, new TestInvocationHandler());
    IClassMetadata facade = facadeFactory.createClassMetadata(classMetadata);
    Assert.assertSame(classMetadata, ((IFacade) facade).getTarget());
}
Also used : ClassMetadata(org.hibernate.metadata.ClassMetadata) IClassMetadata(org.jboss.tools.hibernate.runtime.spi.IClassMetadata) IClassMetadata(org.jboss.tools.hibernate.runtime.spi.IClassMetadata) 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 3 with IClassMetadata

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

the class SessionFactoryFacadeTest method testGetAllClassMetadata.

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

Example 4 with IClassMetadata

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

the class SessionFactoryFacadeTest method testGetAllClassMetadata.

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

Example 5 with IClassMetadata

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

the class SessionFactoryFacadeTest method testGetAllClassMetadata.

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

Aggregations

IClassMetadata (org.jboss.tools.hibernate.runtime.spi.IClassMetadata)19 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 ClassMetadata (org.hibernate.metadata.ClassMetadata)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 EntityPersister (org.hibernate.persister.entity.EntityPersister)2 Annotation (java.lang.annotation.Annotation)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 ServiceRegistry (org.hibernate.service.ServiceRegistry)1 ServiceRegistryBuilder (org.hibernate.service.ServiceRegistryBuilder)1