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);
}
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());
}
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;
}
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;
}
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;
}
Aggregations