Search in sources :

Example 6 with TableHelper

use of org.apache.cayenne.test.jdbc.TableHelper in project cayenne by apache.

the class OneWayRelationshipsIT method setUp.

@Before
public void setUp() throws Exception {
    t1Helper = new TableHelper(dbHelper, "oneway_table1");
    t1Helper.setColumns("ID");
    t2Helper = new TableHelper(dbHelper, "oneway_table2");
    t2Helper.setColumns("ID", "TABLE1_ID");
    t3Helper = new TableHelper(dbHelper, "oneway_table3");
    t3Helper.setColumns("ID");
    t4Helper = new TableHelper(dbHelper, "oneway_table4");
    t4Helper.setColumns("ID", "TABLE3_ID").setColumnTypes(Types.INTEGER, Types.INTEGER);
}
Also used : TableHelper(org.apache.cayenne.test.jdbc.TableHelper) Before(org.junit.Before)

Example 7 with TableHelper

use of org.apache.cayenne.test.jdbc.TableHelper in project cayenne by apache.

the class CAY2509IT method before.

@Before
public void before() {
    this.tArtist = new TableHelper(dbHelper, "ARTIST").setColumns("ARTIST_ID", "ARTIST_NAME", "DATE_OF_BIRTH").setColumnTypes(Types.BIGINT, Types.CHAR, Types.DATE);
    this.tPainting = new TableHelper(dbHelper, "PAINTING").setColumns("PAINTING_ID", "ARTIST_ID", "PAINTING_TITLE").setColumnTypes(Types.INTEGER, Types.BIGINT, Types.VARCHAR);
}
Also used : TableHelper(org.apache.cayenne.test.jdbc.TableHelper) Before(org.junit.Before)

Example 8 with TableHelper

use of org.apache.cayenne.test.jdbc.TableHelper in project cayenne by apache.

the class CayenneDataObjectSetToManyCollectionIT method setUp.

@Before
public void setUp() throws Exception {
    TableHelper tCollectionToMany = new TableHelper(dbHelper, "COLLECTION_TO_MANY");
    tCollectionToMany.setColumns("ID");
    TableHelper tCollectionToManyTarget = new TableHelper(dbHelper, "COLLECTION_TO_MANY_TARGET");
    tCollectionToManyTarget.setColumns("ID", "COLLECTION_TO_MANY_ID");
    // single data set for all tests
    tCollectionToMany.insert(1).insert(2);
    tCollectionToManyTarget.insert(1, 1).insert(2, 1).insert(3, 1).insert(4, 2);
}
Also used : TableHelper(org.apache.cayenne.test.jdbc.TableHelper) Before(org.junit.Before)

Example 9 with TableHelper

use of org.apache.cayenne.test.jdbc.TableHelper in project cayenne by apache.

the class LazyAttributesIT method setup.

@Before
public void setup() throws Exception {
    TableHelper th = new TableHelper(dbHelper, "LAZYBLOB").setColumns("ID", "NAME", "LAZY_DATA").setColumnTypes(Types.INTEGER, Types.VARCHAR, Types.VARBINARY);
    th.insert(1, "test", new byte[] { 1, 2, 3, 4, 5 });
}
Also used : TableHelper(org.apache.cayenne.test.jdbc.TableHelper) Before(org.junit.Before)

Example 10 with TableHelper

use of org.apache.cayenne.test.jdbc.TableHelper in project cayenne by apache.

the class VerticalInheritanceIT method testSelectQuery_MiddleLeaf.

@Test
public void testSelectQuery_MiddleLeaf() throws Exception {
    TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
    ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
    TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
    ivSub1Table.setColumns("ID", "SUB1_NAME");
    TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
    ivSub2Table.setColumns("ID", "SUB2_NAME");
    TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
    ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
    // insert
    ivRootTable.insert(1, "xROOT", null);
    ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
    ivSub1Table.insert(2, "xSUB1");
    ivRootTable.insert(3, "xSUB1_SUB1_ROOT", "IvSub1Sub1");
    ivSub1Table.insert(3, "xSUB1_SUB1_SUBROOT");
    ivSub1Sub1Table.insert(3, "xSUB1_SUB1");
    ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
    ivSub2Table.insert(4, "xSUB2");
    ObjectSelect<IvSub1> query = ObjectSelect.query(IvSub1.class);
    List<IvSub1> results = context.select(query);
    assertEquals(2, results.size());
    // since we don't have ordering, need to analyze results in an order
    // agnostic
    // fashion
    Map<String, IvRoot> resultTypes = new HashMap<>();
    for (IvRoot result : results) {
        resultTypes.put(result.getClass().getName(), result);
    }
    assertEquals(2, resultTypes.size());
    IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
    assertNotNull(sub1);
    assertEquals("xSUB1_ROOT", sub1.getName());
    assertEquals("IvSub1", sub1.getDiscriminator());
    IvSub1Sub1 sub1Sub1 = (IvSub1Sub1) resultTypes.get(IvSub1Sub1.class.getName());
    assertNotNull(sub1Sub1);
    assertEquals("xSUB1_SUB1_ROOT", sub1Sub1.getName());
    assertEquals("IvSub1Sub1", sub1Sub1.getDiscriminator());
    assertEquals("xSUB1_SUB1_SUBROOT", sub1Sub1.getSub1Name());
    assertEquals("xSUB1_SUB1", sub1Sub1.getSub1Sub1Name());
}
Also used : HashMap(java.util.HashMap) TableHelper(org.apache.cayenne.test.jdbc.TableHelper) Test(org.junit.Test)

Aggregations

TableHelper (org.apache.cayenne.test.jdbc.TableHelper)175 Before (org.junit.Before)147 Test (org.junit.Test)19 HashMap (java.util.HashMap)5 DBHelper (org.apache.cayenne.test.jdbc.DBHelper)5 Date (java.util.Date)2 After (org.junit.After)2 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 DataRow (org.apache.cayenne.DataRow)1 ObjectContext (org.apache.cayenne.ObjectContext)1 MapQueryCache (org.apache.cayenne.cache.MapQueryCache)1 DefaultRuntimeProperties (org.apache.cayenne.configuration.DefaultRuntimeProperties)1 OracleAdapter (org.apache.cayenne.dba.oracle.OracleAdapter)1 DefaultEventManager (org.apache.cayenne.event.DefaultEventManager)1 Expression (org.apache.cayenne.exp.Expression)1 EJBQLQuery (org.apache.cayenne.query.EJBQLQuery)1 SQLTemplate (org.apache.cayenne.query.SQLTemplate)1 CAY2666 (org.apache.cayenne.testdo.cay_2666.CAY2666)1 PrimitivesTestEntity (org.apache.cayenne.testdo.primitive.PrimitivesTestEntity)1