db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker InheritanceMultipleTableTest.java
Date Sat, 29 Oct 2005 12:00:25 GMT
arminw      2005/10/29 05:00:25

  Modified:    src/test/org/apache/ojb/broker
                        InheritanceMultipleTableTest.java
  Log:
  add new test to show problem with inheritance in maxDB, minor improvement
  
  Revision  Changes    Path
  1.22      +60 -19    db-ojb/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
  
  Index: InheritanceMultipleTableTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- InheritanceMultipleTableTest.java	22 Oct 2005 20:05:26 -0000	1.21
  +++ InheritanceMultipleTableTest.java	29 Oct 2005 12:00:25 -0000	1.22
  @@ -40,6 +40,49 @@
           broker.serviceBatchManager().setBatchMode(true);
       }
   
  +    public void testLookupByIdentity()
  +    {
  +        long timestamp = System.currentTimeMillis();
  +        Long id_2 = new Long(timestamp);
  +        String name = "testLookupByIdentity_" + timestamp;
  +        Employee em1 = new Employee(id_2, "employee_" + name);
  +        Executive ex1 = new Executive(id_2, "executive_" + name, "department_1", null);
  +        Executive ex2 = new Executive(id_2, "executive_" + name, "department_2", null);
  +        ArrayList list = new ArrayList();
  +        list.add(ex1);
  +        list.add(ex2);
  +        Manager m1 = new Manager(id_2, "manager_" + name);
  +        m1.setExecutives(list);
  +
  +        broker.beginTransaction();
  +        broker.store(em1);
  +        broker.store(m1);
  +        broker.commitTransaction();
  +
  +        Identity m1_oid = broker.serviceIdentity().buildIdentity(m1);
  +        Identity ex1_oid = broker.serviceIdentity().buildIdentity(ex1);
  +        Identity em1_oid = broker.serviceIdentity().buildIdentity(em1);
  +
  +        broker.clearCache();
  +
  +        Employee newEm1 = (Employee) broker.getObjectByIdentity(em1_oid);
  +        Executive newEx1 = (Executive) broker.getObjectByIdentity(ex1_oid);
  +        Manager newM1 = (Manager) broker.getObjectByIdentity(m1_oid);
  +
  +        assertNotNull(newEm1);
  +        assertNotNull(newEx1);
  +        assertNotNull(newM1);
  +        assertEquals(em1.getId(), newEm1.getId());
  +        assertEquals(em1.getId_2(), newEm1.getId_2());
  +        assertEquals(2, newM1.getExecutives().size());
  +
  +        assertEquals(m1.getId(), newM1.getId());
  +        assertEquals(m1.getId_2(), newM1.getId_2());
  +
  +        assertEquals(ex1.getId(), newEx1.getId());
  +        assertEquals(ex1.getId_2(), newEx1.getId_2());
  +    }
  +
       public void testQueryInheritancedObjects()
       {
           if(ojbSkipKnownIssueProblem("Classes mapped to multiple joined tables will always
be instantiated " +
  @@ -931,7 +974,7 @@
       {
           long timestamp = System.currentTimeMillis();
           String name = "testQuery_ReferenceOuterJoin_" + timestamp;
  -        Company company = prepareTestDataWithCompany(name);
  +        prepareTestDataWithCompany(name);
           //Long id_2 = company.getId();
   
           // Store a dummy company
  @@ -946,7 +989,8 @@
           crit.addLike("name", name + "%");
           QueryByCriteria query = QueryFactory.newQuery(Company.class, crit, true);
           Collection result = broker.getCollectionByQuery(query);
  -        assertEquals(2, result.size());								// retrieve both companies
  +        // retrieve both companies
  +        assertEquals(2, result.size());
   
           crit = new Criteria();
           crit.addLike("name", name + "%");
  @@ -961,12 +1005,9 @@
           query = QueryFactory.newQuery(Company.class, crit, true);
           query.addOrderByAscending("id");
           query.setPathOuterJoin("executives");
  -
  -//        SqlGenerator sqlg = broker.serviceSqlGenerator();
  -//        String sql = sqlg.getPreparedSelectStatement(query, broker.getClassDescriptor(Company.class));
  -
           result = broker.getCollectionByQuery(query);
  -        assertEquals(2, result.size());								// should retrieve both companies
  +        // should retrieve both companies
  +        assertEquals(2, result.size());
        }
   
       public void testInsertQuery()
  @@ -988,9 +1029,9 @@
           broker.store(m1);
           broker.commitTransaction();
   
  -        Identity m1_oid = new Identity(m1, broker);
  -        Identity ex1_oid = new Identity(ex1, broker);
  -        Identity em1_oid = new Identity(em1, broker);
  +        Identity m1_oid = broker.serviceIdentity().buildIdentity(m1);
  +        Identity ex1_oid = broker.serviceIdentity().buildIdentity(ex1);
  +        Identity em1_oid = broker.serviceIdentity().buildIdentity(em1);
   
           broker.clearCache();
   
  @@ -1026,7 +1067,7 @@
       {
           long timestamp = System.currentTimeMillis();
           Long id_2 = new Long(timestamp);
  -        String name = "testUpdate" + timestamp;
  +        String name = "testUpdate_" + timestamp;
           Employee em1 = new Employee(id_2, "employee_" + name);
           Executive ex1 = new Executive(id_2, "executive_" + name, "department_1", null);
           Executive ex2 = new Executive(id_2, "executive_" + name, "department_2", null);
  @@ -1041,9 +1082,9 @@
           broker.store(m1);
           broker.commitTransaction();
   
  -        Identity m1_oid = new Identity(m1, broker);
  -        Identity ex1_oid = new Identity(ex1, broker);
  -        Identity em1_oid = new Identity(em1, broker);
  +        Identity m1_oid = broker.serviceIdentity().buildIdentity(m1);
  +        Identity ex1_oid = broker.serviceIdentity().buildIdentity(ex1);
  +        Identity em1_oid = broker.serviceIdentity().buildIdentity(em1);
   
           broker.clearCache();
   
  @@ -1080,7 +1121,7 @@
       {
           long timestamp = System.currentTimeMillis();
           Long id_2 = new Long(timestamp);
  -        String name = "testUpdate" + timestamp;
  +        String name = "testDelete_" + timestamp;
           Employee em1 = new Employee(id_2, "employee_" + name);
           Executive ex1 = new Executive(id_2, "executive_" + name, "department_1", null);
           Executive ex2 = new Executive(id_2, "executive_" + name, "department_2", null);
  @@ -1095,9 +1136,9 @@
           broker.store(m1);
           broker.commitTransaction();
   
  -        Identity m1_oid = new Identity(m1, broker);
  -        Identity ex1_oid = new Identity(ex1, broker);
  -        Identity em1_oid = new Identity(em1, broker);
  +        Identity m1_oid = broker.serviceIdentity().buildIdentity(m1);
  +        Identity ex1_oid = broker.serviceIdentity().buildIdentity(ex1);
  +        Identity em1_oid = broker.serviceIdentity().buildIdentity(em1);
   
           broker.clearCache();
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message