openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1050361 - in /openjpa/branches/2.1.x: openjpa-kernel/src/main/java/org/apache/openjpa/util/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/...
Date Fri, 17 Dec 2010 12:19:47 GMT
Author: curtisr7
Date: Fri Dec 17 12:19:46 2010
New Revision: 1050361

URL: http://svn.apache.org/viewvc?rev=1050361&view=rev
Log:
OPENJPA-1900: Merge changes from trunk. Changes contributed by Mark Struberg.

Added:
    openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/TestEntitySerialize.java
      - copied unchanged from r1050168, openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/TestEntitySerialize.java
Modified:
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java
    openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Annuity.java
    openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/EquityAnnuity.java
    openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuity.java

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java?rev=1050361&r1=1050360&r2=1050361&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java
Fri Dec 17 12:19:46 2010
@@ -127,8 +127,15 @@ public class Proxies {
             ClassMetaData meta = null;          // if null, no proxies?
             boolean useDSFForUnproxy = false;   // default to false for old 1.0 behavior
 
-            // DetachedStateMnager has no context or metadata, so we can't get configuration
settings
-            if (!proxy.getOwner().isDetached()) {
+            // Don't rely on sm.isDetached() method because if we are serializing an attached
Entity
+            // the sm will still be a StateManagerImpl, but isDetached() will return true.
+
+            // Using a DetachedStateManager, so use the new flag since there is no context
or
+            // metadata
+            if (sm instanceof DetachedStateManager) {
+                useDSFForUnproxy = ((DetachedStateManager) sm).getUseDSFForUnproxy();
+            } else{
+                // DetachedStateManager has no context or metadata, so we can't get configuration
settings
                 Compatibility compat = null;
                 meta = sm.getMetaData();
                 if (meta != null) {
@@ -142,9 +149,6 @@ public class Proxies {
                     // new 2.0 behavior of using DetachedStateField to determine unproxy
during serialization
                     useDSFForUnproxy = !compat.getIgnoreDetachedStateFieldForProxySerialization();
                 }
-            } else {
-                // Using a DetachedStateManager, so use the new flag since there is no context
or metadata
-                useDSFForUnproxy = ((DetachedStateManager)sm).getUseDSFForUnproxy();
             }
             
             if (useDSFForUnproxy) {

Modified: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Annuity.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Annuity.java?rev=1050361&r1=1050360&r2=1050361&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Annuity.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Annuity.java
Fri Dec 17 12:19:46 2010
@@ -20,6 +20,7 @@ package org.apache.openjpa.persistence.p
 
 import java.text.DecimalFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import javax.persistence.AttributeOverride;
@@ -28,6 +29,7 @@ import javax.persistence.Column;
 import javax.persistence.DiscriminatorColumn;
 import javax.persistence.DiscriminatorType;
 import javax.persistence.DiscriminatorValue;
+import javax.persistence.ElementCollection;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.Inheritance;
@@ -36,6 +38,9 @@ import javax.persistence.JoinColumn;
 import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
 import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
 
 
 @SuppressWarnings("serial")
@@ -53,7 +58,10 @@ public class Annuity extends AnnuityPers
     private List<IPayout> payouts = new ArrayList<IPayout>();
     private List<IRider> riders = new ArrayList<IRider>();
     private List<IPayor> payors = new ArrayList<IPayor>();
+    private List<String> comments;
+    private Date approvedAt;
     
+    private Annuity previousAnnuity;
     public Annuity(){
     }
 
@@ -134,7 +142,27 @@ public class Annuity extends AnnuityPers
         this.riders = riders;
     }
 
-    
-    
-    
+    @ElementCollection
+    public List<String> getComments() {
+        return comments;
+    }
+    public void setComments(List<String> comments) {
+        this.comments = comments;
+    }
+
+    @Temporal(TemporalType.DATE)
+    public Date getApprovedAt() {
+        return approvedAt;
+    }
+    public void setApprovedAt(Date approvedAt) {
+        this.approvedAt = approvedAt;
+    }
+
+    @OneToOne
+    public Annuity getPreviousAnnuity() {
+        return previousAnnuity;
+    }
+    public void setPreviousAnnuity(Annuity previousAnnuity) {
+        this.previousAnnuity = previousAnnuity;
+    }
 }

Modified: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/EquityAnnuity.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/EquityAnnuity.java?rev=1050361&r1=1050360&r2=1050361&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/EquityAnnuity.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/EquityAnnuity.java
Fri Dec 17 12:19:46 2010
@@ -19,6 +19,7 @@
 package org.apache.openjpa.persistence.proxy.entities;
 
 import java.text.DecimalFormat;
+import java.text.ParseException;
 
 import javax.persistence.Column;
 import javax.persistence.DiscriminatorValue;
@@ -48,12 +49,22 @@ public class EquityAnnuity extends Annui
 		return indexRate;
 	}
 
-	public void setIndexRate(Double indexRate) {
-		this.indexRate = indexRate;
-		if (this.indexRate != null) {
-			DecimalFormat df = new DecimalFormat("#.##");
-			this.indexRate= new Double(df.format(indexRate));
-		}
-	}
+    public void setIndexRate(Double indexRate) {
+        if (indexRate != null) {
+            DecimalFormat df = new DecimalFormat("#.##");
+            try
+            {
+                // parse back via the DateFormat because countries might use ',' as comma
separator
+                this.indexRate= df.parse(df.format(indexRate)).doubleValue();
+            }
+            catch (ParseException e)
+            {
+                throw new RuntimeException(e);
+            }
+        }
+        else {
+            this.indexRate = null;
+        }
+    }
 
 }

Modified: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuity.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuity.java?rev=1050361&r1=1050360&r2=1050361&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuity.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuity.java
Fri Dec 17 12:19:46 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.persistence.proxy.entities;
 
+import java.util.Date;
 import java.util.List;
 
 public interface IAnnuity extends IAnnuityObject {
@@ -45,5 +46,13 @@ public interface IAnnuity extends IAnnui
 	
 	public abstract List<IPayor> getPayors();
 	public abstract void setPayors(List<IPayor> payors);
-	
+
+    public abstract List<String> getComments();
+    public abstract void setComments(List<String> comments);
+
+    public abstract Date getApprovedAt();
+    public void setApprovedAt(Date approvedAt);
+
+    public Annuity getPreviousAnnuity();
+    public void setPreviousAnnuity(Annuity previousAnnuity);
 }



Mime
View raw message