openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1409420 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/...
Date Wed, 14 Nov 2012 21:31:28 GMT
Author: curtisr7
Date: Wed Nov 14 21:31:27 2012
New Revision: 1409420

URL: http://svn.apache.org/viewvc?rev=1409420&view=rev
Log:
OPENJPA-2285: Don't recache data from an Embedded StateManager.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPAEmbeddableDataCache.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/ContactInfo.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Person.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Phone.java
  (with props)
Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java?rev=1409420&r1=1409419&r2=1409420&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
Wed Nov 14 21:31:27 2012
@@ -482,7 +482,8 @@ public class DataCacheStoreManager exten
     private void updateDataCache(boolean found, OpenJPAStateManager sm, FetchConfiguration
fetch,
         boolean loadedFieldsChanged) {
 
-        if (!_ctx.getPopulateDataCache() || sm == null || fetch.getCacheStoreMode() == DataCacheStoreMode.BYPASS)
{
+        if (!_ctx.getPopulateDataCache() || sm == null || sm.isEmbedded()
+            || fetch.getCacheStoreMode() == DataCacheStoreMode.BYPASS) {
             return;
         }
 

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPAEmbeddableDataCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPAEmbeddableDataCache.java?rev=1409420&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPAEmbeddableDataCache.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPAEmbeddableDataCache.java
Wed Nov 14 21:31:27 2012
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.datacache;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+
+import org.apache.openjpa.persistence.datacache.entities.ContactInfo;
+import org.apache.openjpa.persistence.datacache.entities.Person;
+import org.apache.openjpa.persistence.datacache.entities.Phone;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+public class TestJPAEmbeddableDataCache extends SingleEMFTestCase {
+    Object[] params = new Object[] { Person.class, ContactInfo.class, Phone.class, "openjpa.DataCache",
"true",
+        CLEAR_TABLES };
+
+    protected void setUp(Object... props) {
+        super.setUp(params);
+
+    }
+
+    public void test() {
+        EntityManager em = emf.createEntityManager();
+        try {
+            Person p = loadPerson();
+            String sql = "SELECT p.ci FROM Person p WHERE p.id = :id";
+
+            TypedQuery<ContactInfo> query = em.createQuery(sql, ContactInfo.class);
+            query.setParameter("id", p.getId());
+            query.getSingleResult();
+
+            em.clear();
+            query = em.createQuery(sql, ContactInfo.class);
+            query.setParameter("id", p.getId());
+            query.getSingleResult();
+
+        } finally {
+            if (em.getTransaction().isActive())
+                em.getTransaction().rollback();
+            em.close();
+        }
+    }
+
+    Person loadPerson() {
+        Person p = null;
+        EntityManager em = emf.createEntityManager();
+        try {
+            p = new Person();
+            ContactInfo ci = new ContactInfo();
+            Phone phone = new Phone();
+
+            p.setCi(ci);
+            ci.setPhone(phone);
+            phone.setOwner(p);
+
+            p.setFirst("first");
+            p.setMiddle("middle");
+            p.setLast("last");
+
+            phone.setNumber("507-555-1076");
+            phone.setSomethingElse("something-" + System.currentTimeMillis());
+
+            ci.setCity("cittttY");
+            ci.setStreet("street-" + System.currentTimeMillis());
+            ci.setZip("90210");
+
+            em.getTransaction().begin();
+            em.persist(p);
+            em.persist(phone);
+            em.getTransaction().commit();
+
+        } finally {
+            if (em.getTransaction().isActive())
+                em.getTransaction().rollback();
+            em.close();
+        }
+
+        return p;
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPAEmbeddableDataCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/ContactInfo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/ContactInfo.java?rev=1409420&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/ContactInfo.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/ContactInfo.java
Wed Nov 14 21:31:27 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.datacache.entities;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Embeddable;
+import javax.persistence.OneToOne;
+
+@Embeddable
+public class ContactInfo {
+    String city, street, zip;
+
+    @OneToOne(cascade = CascadeType.ALL)
+    Phone phone;
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getStreet() {
+        return street;
+    }
+
+    public void setStreet(String street) {
+        this.street = street;
+    }
+
+    public String getZip() {
+        return zip;
+    }
+
+    public void setZip(String zip) {
+        this.zip = zip;
+    }
+
+    public Phone getPhone() {
+        return phone;
+    }
+
+    public void setPhone(Phone phone) {
+        this.phone = phone;
+    }
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/ContactInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Person.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Person.java?rev=1409420&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Person.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Person.java
Wed Nov 14 21:31:27 2012
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.datacache.entities;
+
+import javax.persistence.Basic;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+@Entity
+@Table(name = "oaopde_person")
+public class Person {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    int id;
+
+    @Version
+    int version;
+
+    @Basic
+    String first, middle, last;
+
+    @Embedded
+    ContactInfo ci;
+
+    public Person() {
+
+    }
+
+    public String getFirst() {
+        return first;
+    }
+
+    public void setFirst(String first) {
+        this.first = first;
+    }
+
+    public String getMiddle() {
+        return middle;
+    }
+
+    public void setMiddle(String middle) {
+        this.middle = middle;
+    }
+
+    public String getLast() {
+        return last;
+    }
+
+    public void setLast(String last) {
+        this.last = last;
+    }
+
+    public ContactInfo getCi() {
+        return ci;
+    }
+
+    public void setCi(ContactInfo ci) {
+        this.ci = ci;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Person.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Phone.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Phone.java?rev=1409420&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Phone.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Phone.java
Wed Nov 14 21:31:27 2012
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.datacache.entities;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+@Entity
+@Table(name = "oaopde_phone")
+public class Phone {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    int id;
+
+    @Version
+    int version;
+
+    String somethingElse;
+    String number;
+
+    @OneToOne(mappedBy = "ci.phone", cascade = CascadeType.ALL)
+    Person owner;
+
+    public Phone() {
+    }
+
+    public String getSomethingElse() {
+        return somethingElse;
+    }
+
+    public void setSomethingElse(String somethingElse) {
+        this.somethingElse = somethingElse;
+    }
+
+    public Person getOwner() {
+        return owner;
+    }
+
+    public void setOwner(Person owner) {
+        this.owner = owner;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setNumber(String n) {
+        number = n;
+    }
+
+    public String getNumber() {
+        return number;
+    }
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/entities/Phone.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message