Search in sources :

Example 16 with JdbcMetadataConfiguration

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();
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) Statement(java.sql.Statement) Connection(java.sql.Connection) JdbcMetadataConfiguration(org.jboss.tools.hibernate.runtime.v_5_6.internal.util.JdbcMetadataConfiguration) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.jupiter.api.Test)

Example 17 with JdbcMetadataConfiguration

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());
}
Also used : JdbcMetadataConfiguration(org.jboss.tools.hibernate.runtime.v_5_3.internal.util.JdbcMetadataConfiguration) Test(org.junit.jupiter.api.Test)

Example 18 with JdbcMetadataConfiguration

use of org.jboss.tools.hibernate.runtime.v_5_5.internal.util.JdbcMetadataConfiguration in project jbosstools-hibernate by jbosstools.

the class ConfigurationFacadeTest method testSetReverseEngineeringStrategy.

@Test
public void testSetReverseEngineeringStrategy() {
    JdbcMetadataConfiguration configuration = new JdbcMetadataConfiguration();
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
    ReverseEngineeringStrategy reverseEngineeringStrategy = new DefaultReverseEngineeringStrategy();
    IReverseEngineeringStrategy strategyFacade = FACADE_FACTORY.createReverseEngineeringStrategy(reverseEngineeringStrategy);
    assertNotSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
    configurationFacade.setReverseEngineeringStrategy(strategyFacade);
    assertSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
}
Also used : IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) JdbcMetadataConfiguration(org.jboss.tools.hibernate.runtime.v_5_3.internal.util.JdbcMetadataConfiguration) IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) DefaultReverseEngineeringStrategy(org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy) ReverseEngineeringStrategy(org.hibernate.cfg.reveng.ReverseEngineeringStrategy) DefaultReverseEngineeringStrategy(org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy) Test(org.junit.jupiter.api.Test)

Example 19 with JdbcMetadataConfiguration

use of org.jboss.tools.hibernate.runtime.v_5_5.internal.util.JdbcMetadataConfiguration in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewJDBCMetaDataConfiguration.

@Test
public void testNewJDBCMetaDataConfiguration() {
    IConfiguration configuration = service.newJDBCMetaDataConfiguration();
    assertNotNull(configuration);
    Object target = ((IFacade) configuration).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof JdbcMetadataConfiguration);
}
Also used : JdbcMetadataConfiguration(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.JdbcMetadataConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.jupiter.api.Test)

Example 20 with JdbcMetadataConfiguration

use of org.jboss.tools.hibernate.runtime.v_5_5.internal.util.JdbcMetadataConfiguration in project jbosstools-hibernate by jbosstools.

the class ConfigurationFacadeTest method testSetReverseEngineeringStrategy.

@Test
public void testSetReverseEngineeringStrategy() {
    JdbcMetadataConfiguration configuration = new JdbcMetadataConfiguration();
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
    RevengStrategy reverseEngineeringStrategy = new DefaultStrategy();
    IReverseEngineeringStrategy strategyFacade = FACADE_FACTORY.createReverseEngineeringStrategy(reverseEngineeringStrategy);
    assertNotSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
    configurationFacade.setReverseEngineeringStrategy(strategyFacade);
    assertSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
}
Also used : RevengStrategy(org.hibernate.tool.api.reveng.RevengStrategy) IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) JdbcMetadataConfiguration(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.JdbcMetadataConfiguration) DefaultStrategy(org.hibernate.tool.internal.reveng.strategy.DefaultStrategy) Test(org.junit.jupiter.api.Test) MetadataHelperTest(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.MetadataHelperTest)

Aggregations

Test (org.junit.jupiter.api.Test)25 Connection (java.sql.Connection)10 Statement (java.sql.Statement)10 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)10 JdbcMetadataConfiguration (org.jboss.tools.hibernate.runtime.v_6_0.internal.util.JdbcMetadataConfiguration)6 Metadata (org.hibernate.boot.Metadata)5 PersistentClass (org.hibernate.mapping.PersistentClass)5 Table (org.hibernate.mapping.Table)5 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)5 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)5 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)5 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)5 JdbcMetadataConfiguration (org.jboss.tools.hibernate.runtime.v_5_3.internal.util.JdbcMetadataConfiguration)5 JdbcMetadataConfiguration (org.jboss.tools.hibernate.runtime.v_5_4.internal.util.JdbcMetadataConfiguration)5 JdbcMetadataConfiguration (org.jboss.tools.hibernate.runtime.v_5_5.internal.util.JdbcMetadataConfiguration)5 JdbcMetadataConfiguration (org.jboss.tools.hibernate.runtime.v_5_6.internal.util.JdbcMetadataConfiguration)5 DefaultReverseEngineeringStrategy (org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy)4 ReverseEngineeringStrategy (org.hibernate.cfg.reveng.ReverseEngineeringStrategy)4 MetadataHelperTest (org.jboss.tools.hibernate.runtime.v_6_0.internal.util.MetadataHelperTest)4 RevengStrategy (org.hibernate.tool.api.reveng.RevengStrategy)2