openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r965640 - in /openjpa/branches/1.2.x: openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ openjpa-persistence-jdbc/src/main/ant/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/
Date Mon, 19 Jul 2010 21:22:16 GMT
Author: mikedd
Date: Mon Jul 19 21:22:16 2010
New Revision: 965640

URL: http://svn.apache.org/viewvc?rev=965640&view=rev
Log:
OPENJPA-1704: Fix PCEnhancer to generate proper readExternal method. Merged to 1.2.x - submitted
by Rick Curtis

Added:
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
  (with props)
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java
  (with props)
Modified:
    openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/main/ant/enhancer.xml

Modified: openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=965640&r1=965639&r2=965640&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
(original)
+++ openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
Mon Jul 19 21:22:16 2010
@@ -114,7 +114,7 @@ public class PCEnhancer {
     // public int getEnhancementContractVersion()
     public static final int ENHANCER_VERSION = 2;
     
-    boolean _addVersionInitFlag = true;
+    boolean _addVersionInitFlag = true; 
 
     public static final int ENHANCE_NONE = 0;
     public static final int ENHANCE_AWARE = 2 << 0;
@@ -3178,15 +3178,14 @@ public class PCEnhancer {
                 // else return false;
                 ifins.setTarget(code.getstatic().setField(Boolean.class, "FALSE", Boolean.class));
             }else{
-                FieldMetaData versionInit = _meta.getDeclaredField(VERSION_INIT_STR);
                 // noop
                 ifins.setTarget(code.nop());
                 // if (pcVersionInit)
                 // return true
                 // else return false;
                 loadManagedInstance(code, false);
-                getfield(code, null, versionInit.getName());
-                ifins = ifDefaultValue(code, versionInit);
+                getfield(code, null, VERSION_INIT_STR);
+                ifins = code.ifeq();
                 code.getstatic().setField(Boolean.class, "TRUE", Boolean.class);
                 code.areturn();
                 ifins.setTarget(code.nop());
@@ -3657,12 +3656,10 @@ public class PCEnhancer {
         addSetManagedValueCode(code, fmd);
         if(fmd.isVersion()==true && _addVersionInitFlag){
             // if we are setting the version, flip the versionInit flag to true
-            FieldMetaData v = _meta.addDeclaredField(VERSION_INIT_STR, boolean.class);
-            v.setTransient(true);
             loadManagedInstance(code, true);
             code.constant().setValue(1);
             // pcVersionInit = true;
-            putfield(code, null, v.getName(), v.getDeclaredType());   
+            putfield(code, null, VERSION_INIT_STR, boolean.class);   
         }
         code.vreturn();
 

Modified: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/main/ant/enhancer.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/main/ant/enhancer.xml?rev=965640&r1=965639&r2=965640&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/main/ant/enhancer.xml (original)
+++ openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/main/ant/enhancer.xml Mon Jul 19 21:22:16
2010
@@ -71,6 +71,7 @@
             <include name="**/*.class" />
             <exclude name="**/Test*.class" />
             <exclude name="**/inheritance/serializable/*.class" />
+            <exclude name="**/detach/serializable/*.class" />
             <exclude name="**/xml/*.class" />
             <exclude name="**/Unenhanced*.class" />
             <exclude name="**/AbstractUnenhanced*.class" />
@@ -86,6 +87,7 @@
             <classpath refid="cp" />
             <fileset dir="${project.build.testOutputDirectory}">
                 <include name="**/inheritance/serializable/*.class" />
+                <include name="**/detach/serializable/*.class" />
                 <!--  include files from orm.xml -->
                 <include name="**/xml/*.class" />
                 <exclude name="**/Test*.class" />

Added: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java?rev=965640&view=auto
==============================================================================
--- openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
(added)
+++ openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
Mon Jul 19 21:22:16 2010
@@ -0,0 +1,48 @@
+/*
+ * 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.detach.serializable;
+
+import java.io.Serializable;
+import java.sql.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Version;
+
+@Entity  
+public class SerializableDetachedStateManager implements Serializable { 
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 80701492251635740L;
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.AUTO)
+    int id;
+
+    @Version
+    int version;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    Date zDate;
+}

Propchange: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java?rev=965640&view=auto
==============================================================================
--- openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java
(added)
+++ openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java
Mon Jul 19 21:22:16 2010
@@ -0,0 +1,44 @@
+/*
+ * 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.detach.serializable;
+
+import java.sql.Date;
+
+import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+public class TestSerializableDetachedStateManager extends SingleEMFTestCase {
+    public void setUp() {
+        setUp(CLEAR_TABLES, SerializableDetachedStateManager.class, DROP_TABLES, "openjpa.DetachState",
+            "fgs(DetachedStateField=true)");
+    }
+    
+    public void testRoundTrip() throws Exception {
+        SerializableDetachedStateManager c = new SerializableDetachedStateManager();
+        c.zDate = new Date(System.currentTimeMillis());
+        OpenJPAEntityManagerSPI em = emf.createEntityManager();
+        
+        em.getTransaction().begin();
+        em.persist(c);
+        em.getTransaction().commit();
+        em.close();
+        AbstractTestCase.roundtrip(c, false);
+    }
+}

Propchange: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message