openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r573398 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
Date Thu, 06 Sep 2007 22:16:12 GMT
Author: mikedd
Date: Thu Sep  6 15:16:10 2007
New Revision: 573398

URL: http://svn.apache.org/viewvc?rev=573398&view=rev
Log:
OPENJPA-353

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

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java?rev=573398&r1=573397&r2=573398&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java
Thu Sep  6 15:16:10 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/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java?rev=573398&r1=573397&r2=573398&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
Thu Sep  6 15:16:10 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();
     }
 



Mime
View raw message