openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r881011 - in /openjpa/trunk: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
Date Mon, 16 Nov 2009 22:23:09 GMT
Author: ppoddar
Date: Mon Nov 16 22:23:09 2009
New Revision: 881011

URL: http://svn.apache.org/viewvc?rev=881011&view=rev
Log:
OPENJPA-1381: Ignore preapared query if lock mode changes

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java?rev=881011&r1=881010&r2=881011&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java
Mon Nov 16 22:23:09 2009
@@ -751,8 +751,11 @@
         em.getTransaction().begin();
         Query q2 = em.createQuery(jpql);
         assertEquals(QueryLanguages.LANG_PREPARED_SQL, OpenJPAPersistence.cast(q2).getLanguage());
+        LockModeType lmode1 = q2.getLockMode();
         q2.setLockMode(LockModeType.OPTIMISTIC);
+        LockModeType lmode2 = q2.getLockMode();
         assertEquals(JPQLParser.LANG_JPQL, OpenJPAPersistence.cast(q2).getLanguage());
+        assertFalse(lmode1.equals(lmode2));
         List<Author> authors2 = q2.getResultList();
         em.getTransaction().rollback();
     }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java?rev=881011&r1=881010&r2=881011&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
Mon Nov 16 22:23:09 2009
@@ -77,7 +77,6 @@
 @SuppressWarnings("serial")
 public class QueryImpl<X> implements OpenJPAQuerySPI<X>, Serializable {
 
-    private static final Object[] EMPTY_ARRAY = new Object[0];
     private static final Localizer _loc = Localizer.forPackage(QueryImpl.class);
 
 	private DelegatingQuery _query;
@@ -86,7 +85,6 @@
 
     private Map<Parameter<?>, Object> _boundParams;
     private Map<Object, Parameter<?>> _declaredParams;
-    private Class<?> _paramKeyType;
 	private String _id;
     private transient ReentrantLock _lock = null;
 	private final HintHandler _hintHandler;
@@ -377,7 +375,11 @@
 	 */
 	void assertJPQLOrCriteriaQuery() {
         String language = getLanguage();
-        if (!(JPQLParser.LANG_JPQL.equals(language) || CriteriaBuilderImpl.LANG_CRITERIA.equals(language)))
{
+        if (JPQLParser.LANG_JPQL.equals(language) 
+         || QueryLanguages.LANG_PREPARED_SQL.equals(language)
+         || CriteriaBuilderImpl.LANG_CRITERIA.equals(language)) {
+            return;
+        } else {
             throw new IllegalStateException(_loc.get("not-jpql-or-criteria-query").getMessage());
         }
 	}



Mime
View raw message