Search in sources :

Example 31 with JDBCReader

use of org.hibernate.cfg.reveng.JDBCReader 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 32 with JDBCReader

use of org.hibernate.cfg.reveng.JDBCReader in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateJDBCReader.

@Test
public void testCreateJDBCReader() {
    JDBCReader jdbcReader = new JDBCReader(null, null, null, null, null, new DefaultReverseEngineeringStrategy());
    IJDBCReader facade = facadeFactory.createJDBCReader(jdbcReader);
    Assert.assertSame(jdbcReader, ((IFacade) facade).getTarget());
}
Also used : DefaultReverseEngineeringStrategy(org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader) JDBCReader(org.hibernate.cfg.reveng.JDBCReader) IJDBCReader(org.jboss.tools.hibernate.runtime.spi.IJDBCReader) Test(org.junit.Test)

Example 33 with JDBCReader

use of org.hibernate.cfg.reveng.JDBCReader in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method collectDatabaseTables.

@Override
public Map<String, List<ITable>> collectDatabaseTables(Properties properties, IReverseEngineeringStrategy strategy, final IProgressListener progressListener) {
    Map<String, List<ITable>> result = new HashMap<String, List<ITable>>();
    JDBCReader jdbcReader = JDBCReaderFactory.newJDBCReader(properties, new Configuration().setProperties(properties).buildSettings(), (ReverseEngineeringStrategy) ((IFacade) strategy).getTarget());
    MetaDataDialect metadataDialect = jdbcReader.getMetaDataDialect();
    DefaultDatabaseCollector databaseCollector = new DefaultDatabaseCollector(metadataDialect);
    ProgressListener progressListenerWrapper = new ProgressListener() {

        @Override
        public void startSubTask(String name) {
            progressListener.startSubTask(name);
        }
    };
    jdbcReader.readDatabaseSchema(databaseCollector, properties.getProperty(Environment.DEFAULT_CATALOG), properties.getProperty(Environment.DEFAULT_SCHEMA), progressListenerWrapper);
    Iterator<?> iterator = databaseCollector.getQualifierEntries();
    while (iterator.hasNext()) {
        Entry<?, ?> entry = (Entry<?, ?>) iterator.next();
        ArrayList<ITable> list = new ArrayList<ITable>();
        for (Object table : (Iterable<?>) entry.getValue()) {
            list.add(facadeFactory.createTable(table));
        }
        result.put((String) entry.getKey(), list);
    }
    return result;
}
Also used : Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration) Configuration(org.hibernate.cfg.Configuration) JDBCMetaDataConfiguration(org.hibernate.cfg.JDBCMetaDataConfiguration) AnnotationConfiguration(org.hibernate.cfg.AnnotationConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Entry(java.util.Map.Entry) IProgressListener(org.jboss.tools.hibernate.runtime.spi.IProgressListener) ProgressListener(org.hibernate.cfg.reveng.ProgressListener) DefaultDatabaseCollector(org.hibernate.cfg.reveng.DefaultDatabaseCollector) List(java.util.List) ArrayList(java.util.ArrayList) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) JDBCReader(org.hibernate.cfg.reveng.JDBCReader)

Example 34 with JDBCReader

use of org.hibernate.cfg.reveng.JDBCReader in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method collectDatabaseTables.

@Override
public Map<String, List<ITable>> collectDatabaseTables(Properties properties, IReverseEngineeringStrategy strategy, final IProgressListener progressListener) {
    Map<String, List<ITable>> result = new HashMap<String, List<ITable>>();
    JDBCReader jdbcReader = JDBCReaderFactory.newJDBCReader(properties, (ReverseEngineeringStrategy) ((IFacade) strategy).getTarget(), buildServiceRegistry(properties));
    MetaDataDialect metadataDialect = jdbcReader.getMetaDataDialect();
    DefaultDatabaseCollector databaseCollector = new DefaultDatabaseCollector(metadataDialect);
    ProgressListener progressListenerWrapper = new ProgressListener() {

        @Override
        public void startSubTask(String name) {
            progressListener.startSubTask(name);
        }
    };
    jdbcReader.readDatabaseSchema(databaseCollector, properties.getProperty(Environment.DEFAULT_CATALOG), properties.getProperty(Environment.DEFAULT_SCHEMA), progressListenerWrapper);
    Iterator<?> iterator = databaseCollector.getQualifierEntries();
    while (iterator.hasNext()) {
        Entry<?, ?> entry = (Entry<?, ?>) iterator.next();
        ArrayList<ITable> list = new ArrayList<ITable>();
        for (Object table : (Iterable<?>) entry.getValue()) {
            list.add(facadeFactory.createTable(table));
        }
        result.put((String) entry.getKey(), list);
    }
    return result;
}
Also used : MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Entry(java.util.Map.Entry) IProgressListener(org.jboss.tools.hibernate.runtime.spi.IProgressListener) ProgressListener(org.hibernate.cfg.reveng.ProgressListener) DefaultDatabaseCollector(org.hibernate.cfg.reveng.DefaultDatabaseCollector) List(java.util.List) ArrayList(java.util.ArrayList) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) JDBCReader(org.hibernate.cfg.reveng.JDBCReader)

Example 35 with JDBCReader

use of org.hibernate.cfg.reveng.JDBCReader in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method collectDatabaseTables.

@Override
public Map<String, List<ITable>> collectDatabaseTables(Properties properties, IReverseEngineeringStrategy strategy, final IProgressListener progressListener) {
    Map<String, List<ITable>> result = new HashMap<String, List<ITable>>();
    JDBCReader jdbcReader = JDBCReaderFactory.newJDBCReader(properties, (ReverseEngineeringStrategy) ((IFacade) strategy).getTarget(), buildServiceRegistry(properties));
    MetaDataDialect metadataDialect = jdbcReader.getMetaDataDialect();
    DefaultDatabaseCollector databaseCollector = new DefaultDatabaseCollector(metadataDialect);
    ProgressListener progressListenerWrapper = new ProgressListener() {

        @Override
        public void startSubTask(String name) {
            progressListener.startSubTask(name);
        }
    };
    jdbcReader.readDatabaseSchema(databaseCollector, properties.getProperty(Environment.DEFAULT_CATALOG), properties.getProperty(Environment.DEFAULT_SCHEMA), progressListenerWrapper);
    Iterator<?> iterator = databaseCollector.getQualifierEntries();
    while (iterator.hasNext()) {
        Entry<?, ?> entry = (Entry<?, ?>) iterator.next();
        ArrayList<ITable> list = new ArrayList<ITable>();
        for (Object table : (Iterable<?>) entry.getValue()) {
            list.add(facadeFactory.createTable(table));
        }
        result.put((String) entry.getKey(), list);
    }
    return result;
}
Also used : MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Entry(java.util.Map.Entry) IProgressListener(org.jboss.tools.hibernate.runtime.spi.IProgressListener) ProgressListener(org.hibernate.cfg.reveng.ProgressListener) DefaultDatabaseCollector(org.hibernate.cfg.reveng.DefaultDatabaseCollector) List(java.util.List) ArrayList(java.util.ArrayList) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) JDBCReader(org.hibernate.cfg.reveng.JDBCReader)

Aggregations

JDBCReader (org.hibernate.cfg.reveng.JDBCReader)35 IJDBCReader (org.jboss.tools.hibernate.runtime.spi.IJDBCReader)24 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)23 DefaultDatabaseCollector (org.hibernate.cfg.reveng.DefaultDatabaseCollector)19 MetaDataDialect (org.hibernate.cfg.reveng.dialect.MetaDataDialect)19 Test (org.junit.Test)16 DefaultReverseEngineeringStrategy (org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy)12 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)11 List (java.util.List)11 Entry (java.util.Map.Entry)11 ProgressListener (org.hibernate.cfg.reveng.ProgressListener)11 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)11 IProgressListener (org.jboss.tools.hibernate.runtime.spi.IProgressListener)11 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)11 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)8 Configuration (org.hibernate.cfg.Configuration)7 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)3 Ejb3Configuration (org.hibernate.ejb.Ejb3Configuration)3 AnnotationConfiguration (org.hibernate.cfg.AnnotationConfiguration)2