Search in sources :

Example 96 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method newReverseEngineeringStrategy.

@Override
public IReverseEngineeringStrategy newReverseEngineeringStrategy(String strategyName, IReverseEngineeringStrategy delegate) {
    assert delegate instanceof IFacade;
    ReverseEngineeringStrategy delegateTarget = (ReverseEngineeringStrategy) ((IFacade) delegate).getTarget();
    Object target = newReverseEngineeringStrategy(strategyName, delegateTarget);
    return facadeFactory.createReverseEngineeringStrategy(target);
}
Also used : IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) DefaultReverseEngineeringStrategy(org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy) ReverseEngineeringStrategy(org.hibernate.cfg.reveng.ReverseEngineeringStrategy) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade)

Example 97 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method newHibernateMappingExporter.

@Override
public IHibernateMappingExporter newHibernateMappingExporter(IConfiguration hcfg, File file) {
    assert hcfg instanceof IFacade;
    ConfigurationFacadeImpl configuration = (ConfigurationFacadeImpl) hcfg;
    Metadata metadata = configuration.getMetadata();
    HibernateMappingExporterExtension target = new HibernateMappingExporterExtension(facadeFactory, (Configuration) ((IFacade) hcfg).getTarget(), file);
    try {
        Field metadataField = AbstractExporter.class.getDeclaredField("metadata");
        metadataField.setAccessible(true);
        metadataField.set(target, metadata);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
    return facadeFactory.createHibernateMappingExporter(target);
}
Also used : Field(java.lang.reflect.Field) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) Metadata(org.hibernate.boot.Metadata) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade)

Example 98 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method newSingleTableSubclass.

@Override
public IPersistentClass newSingleTableSubclass(IPersistentClass persistentClass) {
    assert persistentClass instanceof IFacade;
    IPersistentClass result = facadeFactory.createPersistentClass(new SingleTableSubclass((PersistentClass) ((IFacade) persistentClass).getTarget(), null));
    ((AbstractPersistentClassFacade) result).setSuperClass(persistentClass);
    return result;
}
Also used : AbstractPersistentClassFacade(org.jboss.tools.hibernate.runtime.common.AbstractPersistentClassFacade) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) SingleTableSubclass(org.hibernate.mapping.SingleTableSubclass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 99 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class ConfigurationFacadeTest method testBuildSessionFactory.

@Test
public void testBuildSessionFactory() throws Throwable {
    ISessionFactory sessionFactoryFacade = configurationFacade.buildSessionFactory();
    Assert.assertNotNull(sessionFactoryFacade);
    Object sessionFactory = ((IFacade) sessionFactoryFacade).getTarget();
    Assert.assertNotNull(sessionFactory);
    Assert.assertTrue(sessionFactory instanceof SessionFactory);
}
Also used : ISessionFactory(org.jboss.tools.hibernate.runtime.spi.ISessionFactory) SessionFactory(org.hibernate.SessionFactory) ISessionFactory(org.jboss.tools.hibernate.runtime.spi.ISessionFactory) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.Test)

Example 100 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewTable.

@Test
public void testNewTable() {
    ITable table = service.newTable("foo");
    Assert.assertNotNull(table);
    Object target = ((IFacade) table).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof Table);
    Assert.assertEquals("foo", ((Table) target).getName());
    Assert.assertNotNull(((Table) target).getPrimaryKey());
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.Test)

Aggregations

IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)188 Test (org.junit.Test)156 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)60 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)40 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)29 Configuration (org.hibernate.cfg.Configuration)20 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)20 RootClass (org.hibernate.mapping.RootClass)19 Table (org.hibernate.mapping.Table)15 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)13 File (java.io.File)12 PersistentClass (org.hibernate.mapping.PersistentClass)12 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)12 ISessionFactory (org.jboss.tools.hibernate.runtime.spi.ISessionFactory)12 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)11 Field (java.lang.reflect.Field)9 JDBCReader (org.hibernate.cfg.reveng.JDBCReader)9 IJDBCReader (org.jboss.tools.hibernate.runtime.spi.IJDBCReader)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8