You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2007/09/18 17:25:14 UTC

svn commit: r576948 - in /openjpa/branches/1.0.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/

Author: mikedd
Date: Tue Sep 18 08:25:14 2007
New Revision: 576948

URL: http://svn.apache.org/viewvc?rev=576948&view=rev
Log:
OPENJPA-353 for 1.0.x branch

Modified:
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java
    openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java?rev=576948&r1=576947&r2=576948&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java (original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java Tue Sep 18 08:25:14 2007
@@ -112,7 +112,8 @@
             && base.getJoinablePCSubclassMappings().length == 0))
             return base.getDescribedType();
 
-        Object cls = res.getObject(disc.getColumns()[0], -1, null);
+        Object cls =
+                res.getObject(disc.getColumns()[0], disc.getJavaType(), null);
         return getClass(cls, store);
     }
 

Modified: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java?rev=576948&r1=576947&r2=576948&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java (original)
+++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java Tue Sep 18 08:25:14 2007
@@ -50,7 +50,24 @@
         discrim = getMapping("CharRootEntity").getDiscriminator();
         assertEquals(new Character('R'), discrim.getValue());
         assertEquals(JavaTypes.CHAR, discrim.getJavaType());
-
+        
+        CharLeafEntity leaf = new CharLeafEntity();
+        CharRootEntity root = new CharRootEntity();
+        em.getTransaction().begin();
+        em.persist(leaf);
+        em.persist(root);
+        em.getTransaction().commit();
+        
+        em.refresh(leaf);
+        em.refresh(root);
+        
+        em.clear();
+        
+        CharLeafEntity leaf2 = em.find(CharLeafEntity.class, leaf.getId());
+        CharRootEntity root2 = em.find(CharRootEntity.class, root.getId());
+        
+        assertNotNull(leaf2);
+        assertNotNull(root2);
         em.close();
     }
 
@@ -71,6 +88,25 @@
         assertEquals(new Integer(10101), discrim.getValue());
         assertEquals(JavaTypes.INT, discrim.getJavaType());
 
+        IntegerLeafEntity leaf = new IntegerLeafEntity();
+        IntegerRootEntity root = new IntegerRootEntity();
+        em.getTransaction().begin();
+        em.persist(leaf);
+        em.persist(root);
+        em.getTransaction().commit();
+        
+        em.refresh(leaf);
+        em.refresh(root);
+        
+        em.clear();
+
+        IntegerLeafEntity leaf2 =
+                em.find(IntegerLeafEntity.class, leaf.getId());
+        IntegerRootEntity root2 =
+                em.find(IntegerRootEntity.class, root.getId());
+        
+        assertNotNull(leaf2);
+        assertNotNull(root2);
         em.close();
     }
 
@@ -88,6 +124,24 @@
         discrim = getMapping("StringRootEntity").getDiscriminator();
         assertEquals("StringRoot", discrim.getValue());
         assertEquals(JavaTypes.STRING, discrim.getJavaType());
+        
+        StringLeafEntity leaf = new StringLeafEntity();
+        StringRootEntity root = new StringRootEntity();
+        em.getTransaction().begin();
+        em.persist(leaf);
+        em.persist(root);
+        em.getTransaction().commit();
+        
+        em.refresh(leaf);
+        em.refresh(root);
+        
+        em.clear();
+        
+        StringLeafEntity leaf2 = em.find(StringLeafEntity.class, leaf.getId());
+        StringRootEntity root2 = em.find(StringRootEntity.class, root.getId());
+        
+        assertNotNull(leaf2);
+        assertNotNull(root2);
         em.close();
     }