db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r382599 - /db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
Date Fri, 03 Mar 2006 01:18:18 GMT
Author: arminw
Date: Thu Mar  2 17:18:15 2006
New Revision: 382599

URL: http://svn.apache.org/viewcvs?rev=382599&view=rev
Log:
add new test to show table-per-subclass inheritance bug

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java?rev=382599&r1=382598&r2=382599&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
Thu Mar  2 17:18:15 2006
@@ -34,6 +34,41 @@
         junit.textui.TestRunner.main(new String[]{InheritanceMultipleTableTest.class.getName()});
     }
 
+    /**
+     * Bug:
+     * this test show a problem when using table-per-subclass inheritance
+     * and method PB.getByIdentity. When the real class of the Identity is not
+     * correct the returned object has the wrong type. For table-per-class inheritance strategy
+     * this behavior will be correct, but in this case OJB should anyway detect the correct
+     * type of the result.
+     * Strange: When set logging property
+     * org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.LogLevel=DEBUG
+     * instead of WARN, the test will pass.
+     */
+    public void testLookupByIdentity_2()
+    {
+        long timestamp = System.currentTimeMillis();
+        Long id_2 = new Long(timestamp);
+        String name = "testLookupByIdentity_2_" + timestamp;
+        Executive ex1 = new Executive(id_2, "executive_" + name, "department_1", null);
+
+        broker.beginTransaction();
+        broker.store(ex1);
+        broker.commitTransaction();
+        broker.clearCache();
+
+        // we build the Identity with "wrong" real class specified
+        // (which is Executive, not Employee), but this shouldn't matter
+        // because OJB should detect the correct type on query
+        Identity employee_oid = broker.serviceIdentity().buildIdentity(
+                Employee.class, new String[]{"id", "id_2"}, new Object[]{ex1.getId(), ex1.getId_2()});
+        Object result = broker.getObjectByIdentity(employee_oid);
+
+        //System.out.println("Result: " + result);
+        assertEquals(Executive.class.getName(), result.getClass().getName());
+        assertEquals(ex1, result);
+    }
+
     public void testLookupByIdentity()
     {
         long timestamp = System.currentTimeMillis();



---------------------------------------------------------------------
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