openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgras...@apache.org
Subject svn commit: r1802529 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/compositepk/TestCompositePrimaryKeys.java
Date Thu, 20 Jul 2017 20:11:40 GMT
Author: jgrassel
Date: Thu Jul 20 20:11:40 2017
New Revision: 1802529

URL: http://svn.apache.org/viewvc?rev=1802529&view=rev
Log:
OPENJPA-2705: ArrayOutOfBoundsException occurs with an @EmbeddedId (commit on wdazeys behalf)

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/compositepk/TestCompositePrimaryKeys.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java?rev=1802529&r1=1802528&r2=1802529&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
Thu Jul 20 20:11:40 2017
@@ -269,7 +269,7 @@ public class ClassMapping
                 // If on the other hand we are dealing with an embeddable that is an @IdClass,
fms.size will be the 
                 // number columns in the @IdClass.  Furthermore, when dealing with @IdClass,
'ret' will already  
                 // properly contain the column values, therefore no further processing is
needed.
-                if (fmsPK[0].isEmbedded() && cols.length > 1 && fms.size()
== 1) {
+                if (fmsPK.length > 0 && fmsPK[0].isEmbedded() && cols.length
> 1 && fms.size() == 1) {
                     // OK, we know this PK is an embeddable. So get the individual field
values.
                     Object[] tmpRet = new Object[cols.length];
                     for (int i = 0; i < cols.length; i++) {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/compositepk/TestCompositePrimaryKeys.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/compositepk/TestCompositePrimaryKeys.java?rev=1802529&r1=1802528&r2=1802529&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/compositepk/TestCompositePrimaryKeys.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/compositepk/TestCompositePrimaryKeys.java
Thu Jul 20 20:11:40 2017
@@ -19,10 +19,12 @@
 package org.apache.openjpa.persistence.embed.compositepk;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityTransaction;
+import javax.persistence.Query;
 import javax.persistence.TypedQuery;
 import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
@@ -111,7 +113,7 @@ public class TestCompositePrimaryKeys ex
      * 
      * ArgumentException: An error occurred while parsing the query filter 'select distinct
g from Topic g where
      * t.subject.key = :subjectKey'. Error message: JPQL query does not support conditional
expression over embeddable
-     * class. JPQL string: "key".
+     * class. JPQL string: "key". See section 4.6.3 of the JPA 2.0 specification.
      * 
      * The message in the exception tells it all. Per the spec, you can not do a compare
on embeddables.
      */
@@ -188,6 +190,23 @@ public class TestCompositePrimaryKeys ex
     }
 
     /*
+     * Due to the fix #1 (see notes above), this fails on OJ with:
+     * 
+     * java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
+     * at org.apache.openjpa.jdbc.meta.ClassMapping.toDataStoreValue(ClassMapping.java:272)
+     * 
+     */
+    public void testFindUsingJPQLSubjectKeyIn() { 
+        Query query = em.createQuery("select distinct s from Subject s where s.key in :subjectKeyList");
+        query.setParameter("subjectKeyList", 
+                Arrays.asList(
+                    new SubjectKey(1, "Type"), 
+                    new SubjectKey(2, "Type2"), 
+                    new SubjectKey(3, "Type3")));
+        query.getResultList();
+    }
+
+    /*
      * Prior to the fix #1 (see notes above), this fails on OJ with:
      * 
      * java.lang.ClassCastException: org.apache.openjpa.persistence.embed.compositepk.SubjectKey
cannot be cast to 



Mime
View raw message