openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1339917 - in /openjpa/branches/1.0.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimisticDisable.java
Date Thu, 17 May 2012 23:01:48 GMT
Author: hthomann
Date: Thu May 17 23:01:47 2012
New Revision: 1339917

URL: http://svn.apache.org/viewvc?rev=1339917&view=rev
Log:
OPENJPA-2198: Applied Helen Xu's patch for 1.0.x

Added:
    openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimisticDisable.java
  (with props)
Modified:
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java?rev=1339917&r1=1339916&r2=1339917&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
Thu May 17 23:01:47 2012
@@ -63,7 +63,7 @@ public abstract class AbstractVersionStr
     public boolean checkVersion(OpenJPAStateManager sm, JDBCStore store,
         boolean updateVersion)
         throws SQLException {
-        return false;
+        return !updateVersion;
     }
 
     public int compareVersion(Object v1, Object v2) {

Added: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimisticDisable.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimisticDisable.java?rev=1339917&view=auto
==============================================================================
--- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimisticDisable.java
(added)
+++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimisticDisable.java
Thu May 17 23:01:47 2012
@@ -0,0 +1,49 @@
+package org.apache.openjpa.persistence.jdbc;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Query;
+
+import org.apache.openjpa.persistence.simple.Person;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+public class TestOptimisticDisable extends SQLListenerTestCase{
+	
+	public void setUp() {
+        setUp(Person.class, CLEAR_TABLES,
+        		"openjpa.jdbc.TransactionIsolation", "repeatable-read",
+        		"openjpa.Optimistic", "false");
+    }
+	
+	public void testQuery(){
+		Person p1 = new Person();
+        p1.setId(102);
+        p1.setSurname("TestName");
+        Person p2 = new Person();
+        p2.setId(103);
+        p2.setSurname("TestName");
+
+        EntityManager em = emf.createEntityManager();
+
+        em.getTransaction().begin();
+        em.persist(p1);
+        em.persist(p2);
+        em.getTransaction().commit();
+        em.close();
+		
+    	em = emf.createEntityManager();
+        final EntityTransaction tx = em.getTransaction();
+        tx.begin();       
+        final Query q = em.createQuery("SELECT person FROM Person person WHERE person.surname
= :surname");
+        q.setParameter("surname", "TestName");
+        final List<Person> persons = q.getResultList();
+        tx.commit();
+        em.close();
+        assertEquals(2, persons.size());
+	}
+	
+	
+
+}

Propchange: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimisticDisable.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message