Search in sources :

Example 6 with IEntityMetamodel

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

the class FacadeFactoryTest method testCreateEntityMetamodel.

@Test
public void testCreateEntityMetamodel() {
    Configuration configuration = new Configuration();
    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
    builder.applySettings(configuration.getProperties());
    ServiceRegistry serviceRegistry = builder.build();
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
    RootClass rc = new RootClass(null);
    MetadataImplementor m = (MetadataImplementor) MetadataHelper.getMetadata(configuration);
    SimpleValue sv = new SimpleValue(m);
    sv.setNullValue("null");
    sv.setTypeName(Integer.class.getName());
    rc.setIdentifier(sv);
    EntityMetamodel entityMetamodel = new EntityMetamodel(rc, null, sfi);
    IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
    Assert.assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Configuration(org.hibernate.cfg.Configuration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) ServiceRegistry(org.hibernate.service.ServiceRegistry) IEntityMetamodel(org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel) IEntityMetamodel(org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel) EntityMetamodel(org.hibernate.tuple.entity.EntityMetamodel) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 7 with IEntityMetamodel

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

the class FacadeFactoryTest method testCreateEntityMetamodel.

@Test
public void testCreateEntityMetamodel() {
    Configuration configuration = new Configuration();
    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
    builder.applySettings(configuration.getProperties());
    ServiceRegistry serviceRegistry = builder.build();
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
    RootClass rc = new RootClass(null);
    MetadataImplementor m = (MetadataImplementor) MetadataHelper.getMetadata(configuration);
    SimpleValue sv = new SimpleValue(m);
    sv.setNullValue("null");
    sv.setTypeName(Integer.class.getName());
    rc.setIdentifier(sv);
    EntityMetamodel entityMetamodel = new EntityMetamodel(rc, null, sfi);
    IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
    Assert.assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Configuration(org.hibernate.cfg.Configuration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) ServiceRegistry(org.hibernate.service.ServiceRegistry) IEntityMetamodel(org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel) IEntityMetamodel(org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel) EntityMetamodel(org.hibernate.tuple.entity.EntityMetamodel) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 8 with IEntityMetamodel

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

the class FacadeFactoryTest method testCreateEntityMetamodel.

@Test
public void testCreateEntityMetamodel() {
    MetadataSources metadataSources = new MetadataSources();
    StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder();
    ssrb.applySetting("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    MetadataImplementor m = (MetadataImplementor) metadataSources.buildMetadata(ssrb.build());
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) m.buildSessionFactory();
    RootClass rc = new RootClass(null);
    SimpleValue sv = new SimpleValue(m);
    sv.setNullValue("null");
    sv.setTypeName(Integer.class.getName());
    rc.setIdentifier(sv);
    EntityMetamodel entityMetamodel = new EntityMetamodel(rc, null, sfi);
    IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
    Assert.assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) MetadataSources(org.hibernate.boot.MetadataSources) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) IEntityMetamodel(org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel) IEntityMetamodel(org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel) EntityMetamodel(org.hibernate.tuple.entity.EntityMetamodel) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Aggregations

RootClass (org.hibernate.mapping.RootClass)8 SimpleValue (org.hibernate.mapping.SimpleValue)8 EntityMetamodel (org.hibernate.tuple.entity.EntityMetamodel)8 IEntityMetamodel (org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel)8 Test (org.junit.Test)8 Configuration (org.hibernate.cfg.Configuration)7 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)7 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)6 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)5 ServiceRegistry (org.hibernate.service.ServiceRegistry)5 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)4 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)3 Mappings (org.hibernate.cfg.Mappings)3 SessionFactoryImplementor (org.hibernate.engine.SessionFactoryImplementor)2 SessionFactoryImpl (org.hibernate.impl.SessionFactoryImpl)2 MetadataSources (org.hibernate.boot.MetadataSources)1 ServiceRegistryBuilder (org.hibernate.service.ServiceRegistryBuilder)1