Search in sources :

Example 6 with PrimaryKey

use of org.hibernate.mapping.PrimaryKey in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method newTable.

@Override
public ITable newTable(String name) {
    Table target = new Table(name);
    target.setPrimaryKey(new PrimaryKey());
    return facadeFactory.createTable(target);
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) PrimaryKey(org.hibernate.mapping.PrimaryKey)

Example 7 with PrimaryKey

use of org.hibernate.mapping.PrimaryKey in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method newTable.

@Override
public ITable newTable(String name) {
    Table target = new Table(name);
    target.setPrimaryKey(new PrimaryKey());
    return facadeFactory.createTable(target);
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) PrimaryKey(org.hibernate.mapping.PrimaryKey)

Example 8 with PrimaryKey

use of org.hibernate.mapping.PrimaryKey in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateHQLQueryPlan.

@Test
public void testCreateHQLQueryPlan() {
    Configuration configuration = new Configuration();
    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    Mappings mappings = configuration.createMappings();
    Table t = new Table("FOO");
    Column c = new Column("foo");
    t.addColumn(c);
    PrimaryKey key = new PrimaryKey();
    key.addColumn(c);
    t.setPrimaryKey(key);
    Mappings m = configuration.createMappings();
    SimpleValue sv = new SimpleValue(m);
    sv.setNullValue("null");
    sv.setTypeName(Integer.class.getName());
    sv.setTable(t);
    sv.addColumn(c);
    RootClass rc = new RootClass();
    rc.setEntityName("foo");
    rc.setJpaEntityName("foo");
    rc.setIdentifier(sv);
    rc.setTable(t);
    mappings.addClass(rc);
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
    builder.applySettings(configuration.getProperties());
    ServiceRegistry serviceRegistry = builder.build();
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
    Map<String, Filter> filters = Collections.emptyMap();
    HQLQueryPlan hqlQueryPlan = new HQLQueryPlan("from foo", false, filters, sfi);
    IHQLQueryPlan facade = facadeFactory.createHQLQueryPlan(hqlQueryPlan);
    assertSame(hqlQueryPlan, ((IFacade) facade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) PrimaryKey(org.hibernate.mapping.PrimaryKey) IPrimaryKey(org.jboss.tools.hibernate.runtime.spi.IPrimaryKey) IHQLQueryPlan(org.jboss.tools.hibernate.runtime.spi.IHQLQueryPlan) SimpleValue(org.hibernate.mapping.SimpleValue) HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan) IHQLQueryPlan(org.jboss.tools.hibernate.runtime.spi.IHQLQueryPlan) Mappings(org.hibernate.cfg.Mappings) Column(org.hibernate.mapping.Column) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) Filter(org.hibernate.Filter) ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) TableFilter(org.hibernate.cfg.reveng.TableFilter) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) ServiceRegistry(org.hibernate.service.ServiceRegistry) Test(org.junit.jupiter.api.Test)

Example 9 with PrimaryKey

use of org.hibernate.mapping.PrimaryKey in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreatePrimaryKey.

@Test
public void testCreatePrimaryKey() {
    PrimaryKey primaryKey = new PrimaryKey();
    IPrimaryKey facade = facadeFactory.createPrimaryKey(primaryKey);
    assertSame(primaryKey, ((IFacade) facade).getTarget());
}
Also used : PrimaryKey(org.hibernate.mapping.PrimaryKey) IPrimaryKey(org.jboss.tools.hibernate.runtime.spi.IPrimaryKey) IPrimaryKey(org.jboss.tools.hibernate.runtime.spi.IPrimaryKey) Test(org.junit.jupiter.api.Test)

Example 10 with PrimaryKey

use of org.hibernate.mapping.PrimaryKey in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreatePrimaryKey.

@Test
public void testCreatePrimaryKey() {
    PrimaryKey primaryKey = new PrimaryKey(null);
    IPrimaryKey facade = facadeFactory.createPrimaryKey(primaryKey);
    assertSame(primaryKey, ((IFacade) facade).getTarget());
}
Also used : PrimaryKey(org.hibernate.mapping.PrimaryKey) IPrimaryKey(org.jboss.tools.hibernate.runtime.spi.IPrimaryKey) IPrimaryKey(org.jboss.tools.hibernate.runtime.spi.IPrimaryKey) Test(org.junit.jupiter.api.Test)

Aggregations

PrimaryKey (org.hibernate.mapping.PrimaryKey)62 Table (org.hibernate.mapping.Table)49 IPrimaryKey (org.jboss.tools.hibernate.runtime.spi.IPrimaryKey)46 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)46 Test (org.junit.jupiter.api.Test)32 Column (org.hibernate.mapping.Column)15 SimpleValue (org.hibernate.mapping.SimpleValue)12 RootClass (org.hibernate.mapping.RootClass)11 AbstractPrimaryKeyFacade (org.jboss.tools.hibernate.runtime.common.AbstractPrimaryKeyFacade)11 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)11 IHQLQueryPlan (org.jboss.tools.hibernate.runtime.spi.IHQLQueryPlan)11 BeforeEach (org.junit.jupiter.api.BeforeEach)11 Filter (org.hibernate.Filter)10 TableFilter (org.hibernate.cfg.reveng.TableFilter)10 ITableFilter (org.jboss.tools.hibernate.runtime.spi.ITableFilter)10 HQLQueryPlan (org.hibernate.engine.query.spi.HQLQueryPlan)9 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)8 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)8 InvocationHandler (java.lang.reflect.InvocationHandler)7 Method (java.lang.reflect.Method)7