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 11:57:16 GMT
arminw      2005/10/29 04:57:16

  Modified:    src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        InheritanceMultipleTableTest.java
  Log:
  add new test to show problem with inheritance in maxDB, minor improvement
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.7.2.18  +114 -23   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.7.2.17
  retrieving revision 1.7.2.18
  diff -u -r1.7.2.17 -r1.7.2.18
  --- InheritanceMultipleTableTest.java	22 Oct 2005 20:03:33 -0000	1.7.2.17
  +++ InheritanceMultipleTableTest.java	29 Oct 2005 11:57:16 -0000	1.7.2.18
  @@ -34,6 +34,99 @@
           junit.textui.TestRunner.main(new String[]{InheritanceMultipleTableTest.class.getName()});
       }
   
  +    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 testLookupByQuery()
  +    {
  +        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();
  +
  +        Criteria crit = new Criteria();
  +        crit.addEqualTo("name", "employee_" + name);
  +        Query q = QueryFactory.newQuery(Employee.class, crit);
  +        Employee newEm1 = (Employee) broker.getObjectByQuery(q);
  +
  +        crit = new Criteria();
  +        crit.addEqualTo("name", "executive_" + name);
  +        q = QueryFactory.newQuery(Employee.class, crit);
  +        Executive newEx1 = (Executive) broker.getObjectByQuery(q);
  +
  +        crit = new Criteria();
  +        crit.addEqualTo("name", "manager_" + name);
  +        q = QueryFactory.newQuery(Employee.class, crit);
  +        Manager newM1 = (Manager) broker.getObjectByQuery(q);
  +        
  +        broker.clearCache();
  +
  +        assertNotNull(newEm1);
  +        assertNotNull(newEx1);
  +        assertNotNull(newM1);
  +        assertEquals(2, newM1.getExecutives().size());
  +        assertEquals(em1.getId(), newEm1.getId());
  +        assertEquals(em1.getId_2(), newEm1.getId_2());
  +
  +        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 " +
  @@ -925,7 +1018,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
  @@ -940,27 +1033,25 @@
           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 + "%");
  -        
  +
           Criteria nameCrit1 = new Criteria();
           nameCrit1.addLike("executives.name", name + "%");
           Criteria nameCrit2 = new Criteria();
           nameCrit2.addIsNull("executives.name");
           nameCrit1.addOrCriteria(nameCrit2);
           crit.addAndCriteria(nameCrit1);
  -        
  +
           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));
  -
  +        query.setPathOuterJoin("executives");
           result = broker.getCollectionByQuery(query);
  -        assertEquals(2, result.size());								// should retrieve both companies
  +        // should retrieve both companies
  +        assertEquals(2, result.size());
        }
       
       public void testInsertQuery()
  @@ -982,9 +1073,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();
   
  @@ -1020,7 +1111,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);
  @@ -1035,9 +1126,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();
   
  @@ -1074,7 +1165,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);
  @@ -1089,9 +1180,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