Search in sources :

Example 86 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 : 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_3.internal.util.JdbcMetadataConfiguration) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 87 with ITable

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

the class ServiceImplTest method testNewManyToOne.

@Test
public void testNewManyToOne() {
    ITable table = service.newTable("foo");
    IValue manyToOne = service.newManyToOne(table);
    Assert.assertNotNull(manyToOne);
    Object target = ((IFacade) manyToOne).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof ManyToOne);
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) ManyToOne(org.hibernate.mapping.ManyToOne) Test(org.junit.Test)

Example 88 with ITable

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

the class TableFacadeTest method testAddColumn.

@Test
public void testAddColumn() {
    Table table = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(table);
    Column column = new Column("foo");
    IColumn columnFacade = FACADE_FACTORY.createColumn(column);
    Assert.assertNull(table.getColumn(column));
    tableFacade.addColumn(columnFacade);
    Assert.assertSame(column, table.getColumn(column));
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Column(org.hibernate.mapping.Column) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 89 with ITable

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

the class TableFacadeTest method testIsAbstract.

@Test
public void testIsAbstract() {
    Table table = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(table);
    table.setAbstract(true);
    Assert.assertTrue(tableFacade.isAbstract());
    table.setAbstract(false);
    Assert.assertFalse(tableFacade.isAbstract());
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 90 with ITable

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

the class TableFacadeTest method testGetIdentifierValue.

@Test
public void testGetIdentifierValue() {
    Table table = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(table);
    IValue valueFacade = tableFacade.getIdentifierValue();
    Assert.assertNull(valueFacade);
    KeyValue value = new SimpleValue(null);
    table.setIdentifierValue(value);
    valueFacade = tableFacade.getIdentifierValue();
    Assert.assertSame(value, ((IFacade) valueFacade).getTarget());
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) KeyValue(org.hibernate.mapping.KeyValue) 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