Search in sources :

Example 61 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable 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();
}
Also used : JDBCMetaDataConfiguration(org.hibernate.cfg.JDBCMetaDataConfiguration) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) Statement(java.sql.Statement) Connection(java.sql.Connection) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 62 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateTable.

@Test
public void testCreateTable() {
    Table table = new Table();
    ITable facade = facadeFactory.createTable(table);
    Assert.assertSame(table, ((IFacade) facade).getTarget());
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 63 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testSetTable.

@Test
public void testSetTable() {
    Table tableTarget = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(tableTarget);
    SimpleValue valueTarget = new SimpleValue(null);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    Assert.assertNull(valueTarget.getTable());
    valueFacade.setTable(tableFacade);
    Assert.assertSame(tableTarget, valueTarget.getTable());
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 64 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testSetCollectionTable.

@Test
public void testSetCollectionTable() {
    Table tableTarget = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(tableTarget);
    Collection valueTarget = new Set(null, null);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    Assert.assertNull(valueTarget.getCollectionTable());
    valueFacade.setCollectionTable(tableFacade);
    Assert.assertSame(tableTarget, valueTarget.getCollectionTable());
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) Set(org.hibernate.mapping.Set) Collection(org.hibernate.mapping.Collection) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 65 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testGetTable.

@Test
public void testGetTable() {
    Table tableTarget = new Table();
    valueTarget = new SimpleValue(null, tableTarget);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    ITable tableFacade = valueFacade.getTable();
    Assert.assertSame(tableTarget, ((IFacade) tableFacade).getTarget());
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Aggregations

ITable (org.jboss.tools.hibernate.runtime.spi.ITable)209 Table (org.hibernate.mapping.Table)180 Test (org.junit.Test)173 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)26 SimpleValue (org.hibernate.mapping.SimpleValue)24 Method (java.lang.reflect.Method)17 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)17 Column (org.hibernate.mapping.Column)16 PrimaryKey (org.hibernate.mapping.PrimaryKey)16 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)14 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)12 IPrimaryKey (org.jboss.tools.hibernate.runtime.spi.IPrimaryKey)11 Connection (java.sql.Connection)8 Statement (java.sql.Statement)8 Collection (org.hibernate.mapping.Collection)8 KeyValue (org.hibernate.mapping.KeyValue)8 Set (org.hibernate.mapping.Set)8 ArrayList (java.util.ArrayList)7 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)7 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)7