use of org.hibernate.cfg.JDBCMetaDataConfiguration in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testSetReverseEngineeringStrategy.
@Test
public void testSetReverseEngineeringStrategy() {
JDBCMetaDataConfiguration configuration = new JDBCMetaDataConfiguration();
configurationFacade = FACADE_FACTORY.createConfiguration(configuration);
ReverseEngineeringStrategy reverseEngineeringStrategy = new DefaultReverseEngineeringStrategy();
IReverseEngineeringStrategy strategyFacade = FACADE_FACTORY.createReverseEngineeringStrategy(reverseEngineeringStrategy);
Assert.assertNotSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
configurationFacade.setReverseEngineeringStrategy(strategyFacade);
Assert.assertSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
}
use of org.hibernate.cfg.JDBCMetaDataConfiguration in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testGetTableMappings.
@Test
public void testGetTableMappings() throws Exception {
Connection connection = DriverManager.getConnection("jdbc:h2:mem:test");
Statement statement = connection.createStatement();
statement.execute("CREATE TABLE FOO(id int primary key, bar varchar(255))");
JDBCMetaDataConfiguration jdbcMdCfg = new JDBCMetaDataConfiguration();
jdbcMdCfg.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
configurationFacade = FACADE_FACTORY.createConfiguration(jdbcMdCfg);
Iterator<ITable> iterator = configurationFacade.getTableMappings();
Assert.assertFalse(iterator.hasNext());
jdbcMdCfg.readFromJDBC();
configurationFacade = FACADE_FACTORY.createConfiguration(jdbcMdCfg);
iterator = configurationFacade.getTableMappings();
Table table = (Table) ((IFacade) iterator.next()).getTarget();
Assert.assertEquals("FOO", table.getName());
statement.execute("DROP TABLE FOO");
}
use of org.hibernate.cfg.JDBCMetaDataConfiguration in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testReadFromJDBC.
@Test
public void testReadFromJDBC() throws Exception {
Connection connection = DriverManager.getConnection("jdbc:h2:mem:test");
Statement statement = connection.createStatement();
statement.execute("CREATE TABLE FOO(id int primary key, bar varchar(255))");
JDBCMetaDataConfiguration jdbcMdCfg = new JDBCMetaDataConfiguration();
jdbcMdCfg.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
configurationFacade = FACADE_FACTORY.createConfiguration(jdbcMdCfg);
Metadata metadata = jdbcMdCfg.getMetadata();
Iterator<?> iterator = metadata.getEntityBindings().iterator();
jdbcMdCfg = new JDBCMetaDataConfiguration();
jdbcMdCfg.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
configurationFacade = FACADE_FACTORY.createConfiguration(jdbcMdCfg);
Assert.assertFalse(iterator.hasNext());
configurationFacade.readFromJDBC();
metadata = jdbcMdCfg.getMetadata();
iterator = metadata.getEntityBindings().iterator();
PersistentClass persistentClass = (PersistentClass) iterator.next();
Assert.assertEquals("Foo", persistentClass.getClassName());
statement.execute("DROP TABLE FOO");
connection.close();
}
use of org.hibernate.cfg.JDBCMetaDataConfiguration in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testSetPreferBasicCompositeIds.
@Test
public void testSetPreferBasicCompositeIds() {
JDBCMetaDataConfiguration configuration = new JDBCMetaDataConfiguration();
configurationFacade = FACADE_FACTORY.createConfiguration(configuration);
// the default is false
Assert.assertTrue(configuration.preferBasicCompositeIds());
configurationFacade.setPreferBasicCompositeIds(false);
Assert.assertFalse(configuration.preferBasicCompositeIds());
}
use of org.hibernate.cfg.JDBCMetaDataConfiguration in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testGetTableMappings.
@Test
public void testGetTableMappings() throws Exception {
Connection connection = DriverManager.getConnection("jdbc:h2:mem:test");
Statement statement = connection.createStatement();
statement.execute("CREATE TABLE FOO(id int primary key, bar varchar(255))");
JDBCMetaDataConfiguration jdbcMdCfg = new JDBCMetaDataConfiguration();
jdbcMdCfg.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
configurationFacade = FACADE_FACTORY.createConfiguration(jdbcMdCfg);
Iterator<ITable> iterator = configurationFacade.getTableMappings();
Assert.assertFalse(iterator.hasNext());
jdbcMdCfg.readFromJDBC();
configurationFacade = FACADE_FACTORY.createConfiguration(jdbcMdCfg);
iterator = configurationFacade.getTableMappings();
Table table = (Table) ((IFacade) iterator.next()).getTarget();
Assert.assertEquals("FOO", table.getName());
statement.execute("DROP TABLE FOO");
connection.close();
}
Aggregations