Search in sources :

Example 16 with IJDBCReader

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

the class ServiceImplTest method testNewJDBCReader.

@Test
public void testNewJDBCReader() {
    IConfiguration configuration = service.newDefaultConfiguration();
    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    IReverseEngineeringStrategy strategy = service.newDefaultReverseEngineeringStrategy();
    IJDBCReader jdbcReader = service.newJDBCReader(configuration, strategy);
    Assert.assertNotNull(jdbcReader);
    Object target = ((IFacade) jdbcReader).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof JDBCReader);
}
Also used : IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader) JDBCReader(org.hibernate.cfg.reveng.JDBCReader) Test(org.junit.Test)

Example 17 with IJDBCReader

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

the class ServiceImplTest method testNewJDBCReader.

@Test
public void testNewJDBCReader() {
    IConfiguration configuration = service.newDefaultConfiguration();
    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    IReverseEngineeringStrategy strategy = service.newDefaultReverseEngineeringStrategy();
    IJDBCReader jdbcReader = service.newJDBCReader(configuration, strategy);
    Assert.assertNotNull(jdbcReader);
    Object target = ((IFacade) jdbcReader).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof JDBCReader);
}
Also used : IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader) JDBCReader(org.hibernate.cfg.reveng.JDBCReader) Test(org.junit.Test)

Example 18 with IJDBCReader

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

the class LazyDatabaseSchemaWorkbenchAdapter method readDatabaseSchema.

protected IDatabaseCollector readDatabaseSchema(final IProgressMonitor monitor, final ConsoleConfiguration consoleConfiguration, final IReverseEngineeringStrategy strategy) {
    final IConfiguration configuration = consoleConfiguration.buildWith(null, false);
    return (IDatabaseCollector) consoleConfiguration.execute(new ExecutionContext.Command() {

        public Object execute() {
            IDatabaseCollector db = null;
            try {
                IService service = consoleConfiguration.getHibernateExtension().getHibernateService();
                IJDBCReader reader = service.newJDBCReader(configuration, strategy);
                db = service.newDatabaseCollector(reader);
                reader.readDatabaseSchema(db, new ProgressListener(monitor));
            } catch (UnsupportedOperationException he) {
                throw new HibernateException(he);
            } catch (Exception he) {
                he.printStackTrace();
                throw new HibernateException(he.getMessage(), he.getCause());
            }
            return db;
        }
    });
}
Also used : IProgressListener(org.jboss.tools.hibernate.runtime.spi.IProgressListener) HibernateException(org.jboss.tools.hibernate.runtime.spi.HibernateException) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IDatabaseCollector(org.jboss.tools.hibernate.runtime.spi.IDatabaseCollector) IService(org.jboss.tools.hibernate.runtime.spi.IService) HibernateException(org.jboss.tools.hibernate.runtime.spi.HibernateException) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader)

Example 19 with IJDBCReader

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

the class ServiceImpl method newDatabaseCollector.

@Override
public IDatabaseCollector newDatabaseCollector(IJDBCReader jdbcReader) {
    assert jdbcReader instanceof IFacade;
    JDBCReader jdbcReaderTarget = (JDBCReader) ((IFacade) jdbcReader).getTarget();
    MetaDataDialect metadataDialect = jdbcReaderTarget.getMetaDataDialect();
    return facadeFactory.createDatabaseCollector(new DefaultDatabaseCollector(metadataDialect));
}
Also used : MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) DefaultDatabaseCollector(org.hibernate.cfg.reveng.DefaultDatabaseCollector) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader) JDBCReader(org.hibernate.cfg.reveng.JDBCReader)

Example 20 with IJDBCReader

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

the class ServiceImpl method newDatabaseCollector.

@Override
public IDatabaseCollector newDatabaseCollector(IJDBCReader jdbcReader) {
    assert jdbcReader instanceof IFacade;
    JDBCReader jdbcReaderTarget = (JDBCReader) ((IFacade) jdbcReader).getTarget();
    MetaDataDialect metadataDialect = jdbcReaderTarget.getMetaDataDialect();
    return facadeFactory.createDatabaseCollector(new DefaultDatabaseCollector(metadataDialect));
}
Also used : MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) DefaultDatabaseCollector(org.hibernate.cfg.reveng.DefaultDatabaseCollector) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader) JDBCReader(org.hibernate.cfg.reveng.JDBCReader)

Aggregations

IJDBCReader (org.jboss.tools.hibernate.runtime.spi.IJDBCReader)33 JDBCReader (org.hibernate.cfg.reveng.JDBCReader)24 Test (org.junit.Test)24 DefaultReverseEngineeringStrategy (org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy)20 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)17 Configuration (org.hibernate.cfg.Configuration)12 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)12 IDatabaseCollector (org.jboss.tools.hibernate.runtime.spi.IDatabaseCollector)9 DatabaseCollector (org.hibernate.cfg.reveng.DatabaseCollector)8 DefaultDatabaseCollector (org.hibernate.cfg.reveng.DefaultDatabaseCollector)8 MetaDataDialect (org.hibernate.cfg.reveng.dialect.MetaDataDialect)8 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)8 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)5 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)3 AnnotationConfiguration (org.hibernate.cfg.AnnotationConfiguration)2 ServiceRegistry (org.hibernate.service.ServiceRegistry)1 ServiceRegistryBuilder (org.hibernate.service.ServiceRegistryBuilder)1 HibernateException (org.jboss.tools.hibernate.runtime.spi.HibernateException)1 IProgressListener (org.jboss.tools.hibernate.runtime.spi.IProgressListener)1 IService (org.jboss.tools.hibernate.runtime.spi.IService)1