openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r956875 - in /openjpa/trunk: 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 Tue, 22 Jun 2010 13:08:36 GMT
Author: curtisr7
Date: Tue Jun 22 13:08:35 2010
New Revision: 956875

URL: http://svn.apache.org/viewvc?rev=956875&view=rev
Log:
OPENJPA-1704: Fix PCEnhancer to generate proper readExternal method.

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

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=956875&r1=956874&r2=956875&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
Tue Jun 22 13:08:35 2010
@@ -117,7 +117,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;
@@ -2772,7 +2772,7 @@ public class PCEnhancer {
         _pc.declareField(PRE + "FieldTypes", Class[].class).setStatic(true);
         _pc.declareField(PRE + "FieldFlags", byte[].class).setStatic(true);
         _pc.declareField(SUPER, Class.class).setStatic(true);
-        if(_addVersionInitFlag && _meta.getVersionField()!=null){
+        if (_addVersionInitFlag && _meta.getVersionField() != null) {
             // protected transient boolean pcVersionInit;
             BCField field = _pc.declareField(VERSION_INIT_STR, boolean.class);
             field.makeProtected();
@@ -3229,17 +3229,15 @@ public class PCEnhancer {
             if (!_addVersionInitFlag){
                 // else return false;
                 ifins.setTarget(code.getstatic().setField(Boolean.class, "FALSE", Boolean.class));
-            }else{
-                FieldMetaData versionInit = _meta.getDeclaredField(VERSION_INIT_STR);
-                
+            }else{              
                 // noop
                 ifins.setTarget(code.nop());
                 // if (pcVersionInit != false)
                 // 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());
@@ -3709,12 +3707,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/trunk/openjpa-persistence-jdbc/src/main/ant/enhancer.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/ant/enhancer.xml?rev=956875&r1=956874&r2=956875&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/ant/enhancer.xml (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/ant/enhancer.xml Tue Jun 22 13:08:35 2010
@@ -75,6 +75,7 @@
                  dir="${project.build.testOutputDirectory}">
             <include name="**/*.class" />
             <exclude name="**/inheritance/serializable/*.class" />
+            <exclude name="**/detach/serializable/*.class" />
             <exclude name="**/xml/*.class" />
             <exclude name="**/Unenhanced*.class" />
             <exclude name="**/AbstractUnenhanced*.class" />
@@ -92,6 +93,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="**/persistence/delimited/identifiers/xml/*.class"/>

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java?rev=956875&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
Tue Jun 22 13:08:35 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/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/SerializableDetachedStateManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java?rev=956875&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/serializable/TestSerializableDetachedStateManager.java
Tue Jun 22 13:08:35 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.test.AbstractPersistenceTestCase;
+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();
+        AbstractPersistenceTestCase.roundtrip(c);
+    }
+}

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



Mime
View raw message