use of org.jboss.tools.hibernate.runtime.v_5_5.internal.util.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 = new ConfigurationFacadeImpl(FACADE_FACTORY, jdbcMdCfg);
Metadata metadata = jdbcMdCfg.getMetadata();
assertNull(metadata);
jdbcMdCfg = new JdbcMetadataConfiguration();
jdbcMdCfg.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, jdbcMdCfg);
configurationFacade.readFromJDBC();
metadata = jdbcMdCfg.getMetadata();
Iterator<PersistentClass> iterator = metadata.getEntityBindings().iterator();
PersistentClass persistentClass = iterator.next();
assertEquals("Foo", persistentClass.getClassName());
statement.execute("DROP TABLE FOO");
statement.close();
connection.close();
}
use of org.jboss.tools.hibernate.runtime.v_5_5.internal.util.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 = new ConfigurationFacadeImpl(FACADE_FACTORY, jdbcMdCfg);
Iterator<ITable> iterator = configurationFacade.getTableMappings();
assertFalse(iterator.hasNext());
jdbcMdCfg.readFromJDBC();
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, jdbcMdCfg);
iterator = configurationFacade.getTableMappings();
IFacade facade = (IFacade) iterator.next();
Table table = (Table) facade.getTarget();
assertEquals("FOO", table.getName());
statement.execute("DROP TABLE FOO");
connection.close();
}
use of org.jboss.tools.hibernate.runtime.v_5_5.internal.util.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 = new ConfigurationFacadeImpl(FACADE_FACTORY, jdbcMdCfg);
Metadata metadata = jdbcMdCfg.getMetadata();
assertNull(metadata);
jdbcMdCfg = new JdbcMetadataConfiguration();
jdbcMdCfg.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, jdbcMdCfg);
configurationFacade.readFromJDBC();
metadata = jdbcMdCfg.getMetadata();
Iterator<PersistentClass> iterator = metadata.getEntityBindings().iterator();
PersistentClass persistentClass = iterator.next();
assertEquals("Foo", persistentClass.getClassName());
statement.execute("DROP TABLE FOO");
statement.close();
connection.close();
}
use of org.jboss.tools.hibernate.runtime.v_5_5.internal.util.JdbcMetadataConfiguration in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testSetPreferBasicCompositeIds.
@Test
public void testSetPreferBasicCompositeIds() {
JdbcMetadataConfiguration configuration = new JdbcMetadataConfiguration();
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
// the default is true
assertTrue(configuration.preferBasicCompositeIds());
configurationFacade.setPreferBasicCompositeIds(false);
assertFalse(configuration.preferBasicCompositeIds());
}
use of org.jboss.tools.hibernate.runtime.v_5_5.internal.util.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 = new ConfigurationFacadeImpl(FACADE_FACTORY, jdbcMdCfg);
Iterator<ITable> iterator = configurationFacade.getTableMappings();
assertFalse(iterator.hasNext());
jdbcMdCfg.readFromJdbc();
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, jdbcMdCfg);
iterator = configurationFacade.getTableMappings();
IFacade facade = (IFacade) iterator.next();
Table table = (Table) facade.getTarget();
assertEquals("FOO", table.getName());
statement.execute("DROP TABLE FOO");
connection.close();
}
Aggregations