Search in sources :

Example 1 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 2 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();
    Mappings m = configuration.createMappings();
    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) Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Mappings(org.hibernate.cfg.Mappings) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) 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 3 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");
    ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
    builder.applySettings(configuration.getProperties());
    ServiceRegistry serviceRegistry = builder.buildServiceRegistry();
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
    RootClass rc = new RootClass();
    Mappings m = configuration.createMappings();
    SimpleValue sv = new SimpleValue(m);
    sv.setNullValue("null");
    sv.setTypeName(Integer.class.getName());
    rc.setIdentifier(sv);
    EntityMetamodel entityMetamodel = new EntityMetamodel(rc, sfi);
    IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
    Assert.assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Mappings(org.hibernate.cfg.Mappings) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) 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) ServiceRegistryBuilder(org.hibernate.service.ServiceRegistryBuilder) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 4 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");
    SessionFactoryImplementor sfi = new SessionFactoryImpl(configuration, null, configuration.buildSettings(), null, null);
    RootClass rc = new RootClass();
    SimpleValue sv = new SimpleValue();
    sv.setNullValue("null");
    sv.setTypeName(Integer.class.getName());
    rc.setIdentifier(sv);
    EntityMetamodel entityMetamodel = new EntityMetamodel(rc, sfi);
    IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
    Assert.assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) SessionFactoryImplementor(org.hibernate.engine.SessionFactoryImplementor) SessionFactoryImpl(org.hibernate.impl.SessionFactoryImpl) 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 5 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");
    SessionFactoryImplementor sfi = new SessionFactoryImpl(configuration, null, configuration.buildSettings(), null, null);
    RootClass rc = new RootClass();
    Mappings m = configuration.createMappings();
    SimpleValue sv = new SimpleValue(m);
    sv.setNullValue("null");
    sv.setTypeName(Integer.class.getName());
    rc.setIdentifier(sv);
    EntityMetamodel entityMetamodel = new EntityMetamodel(rc, sfi);
    IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
    Assert.assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Mappings(org.hibernate.cfg.Mappings) SessionFactoryImplementor(org.hibernate.engine.SessionFactoryImplementor) SessionFactoryImpl(org.hibernate.impl.SessionFactoryImpl) 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