cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: Clean up client superclass template Enable force update of generated test classes
Date Wed, 07 Feb 2018 08:44:12 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 750d3d551 -> e591f4d1f


Clean up client superclass template
Enable force update of generated test classes


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/e591f4d1
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/e591f4d1
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/e591f4d1

Branch: refs/heads/master
Commit: e591f4d1fb897b6e173822696ca68773d296f20a
Parents: 750d3d5
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Wed Feb 7 11:37:00 2018 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Wed Feb 7 11:37:00 2018 +0300

----------------------------------------------------------------------
 .../templates/v4_1/client-superclass.vm         | 83 ++++++++++----------
 cayenne-crypto/pom.xml                          |  1 +
 .../apache/cayenne/crypto/db/auto/_Table1.java  | 38 +++++----
 .../apache/cayenne/crypto/db/auto/_Table2.java  | 12 +--
 .../apache/cayenne/crypto/db/auto/_Table3.java  |  6 +-
 .../apache/cayenne/crypto/db/auto/_Table4.java  | 19 +++--
 .../apache/cayenne/crypto/db/auto/_Table5.java  | 39 +++++----
 .../apache/cayenne/crypto/db/auto/_Table6.java  | 26 +++---
 cayenne-protostuff/pom.xml                      |  1 +
 .../persistent/auto/_ClientMtTable1.java        | 13 +--
 .../persistent/auto/_ClientMtTable2.java        |  5 +-
 11 files changed, 135 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm b/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm
index f8c9cbe..0b2ae34 100644
--- a/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm
+++ b/cayenne-cgen/src/main/resources/templates/v4_1/client-superclass.vm
@@ -89,7 +89,7 @@ public abstract class ${superClassName} extends ${baseClassName} {
     public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)}
= Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
 #end
 #else
-    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClassName})" )
+    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})" )
     public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)}
= Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
 #end
 #end
@@ -112,44 +112,43 @@ public abstract class ${superClassName} extends ${baseClassName} {
 
 ## Create attribute set/get methods
 #foreach( $attr in ${object.DeclaredAttributes} )
+#set( $attrName = $stringUtils.formatVariableName(${attr.Name}))
 #if ( $importUtils.isBoolean(${attr.Type}) )
     public boolean is${stringUtils.capitalized($attr.Name)}() {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${attr.Name}", false);
         }
 
-        return ${attr.Name};
+        return $attrName;
     }
+
 #else 
     public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}()
{
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${attr.Name}", false);
         }
 
-        return ${attr.Name};
+        return $attrName;
     }
+
 #end
 #if ("true" != "${object.isReadOnly()}")
-    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type})
$stringUtils.formatVariableName(${attr.Name})) {
+    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type})
$attrName) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${attr.Name}", false);
+            objectContext.propertyChanged(this, "${attr.Name}", this.$attrName, $attrName);
         }
 
-        Object oldValue = this.${stringUtils.formatVariableName($attr.Name)};
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "${attr.Name}", oldValue, $stringUtils.formatVariableName(${attr.Name}));
-        }
-        
-        this.${stringUtils.formatVariableName($attr.Name)} = ${stringUtils.formatVariableName($attr.Name)};
+        this.$attrName = $attrName;
     }
-#end
 
 #end
+#end
 ##
 ##
 ## Create list add/remove/get methods
 #foreach( $rel in ${object.DeclaredRelationships} )
+#set( $relName = $stringUtils.formatVariableName(${rel.Name}))
 #if( $rel.ToMany )
 #if ( ${rel.CollectionType} == "java.util.Map")
     public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)),
$importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> get${stringUtils.capitalized($rel.Name)}()
{
@@ -158,87 +157,87 @@ public abstract class ${superClassName} extends ${baseClassName} {
 #end
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
+        } else if (this.$relName == null) {
 #if ( ${rel.CollectionType} == "java.util.Map")
         	throw new RuntimeException("Map relationships cannot be accessed for transient objects");
 #else
-        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
+        	this.$relName = new PersistentObjectList(this, "${rel.Name}");
 #end
 		}
 
-        return ${rel.Name};
+        return $relName;
     }
+
 #if ( ! $rel.ReadOnly )
 #if ( ${rel.CollectionType} == "java.util.Map")
 	public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})
object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
+        } else if (this.$relName == null) {
         	throw new RuntimeException("Map relationships cannot be accessed for transient objects");
       
         }
 
-        this.${rel.Name}.put(getMapKey("${rel.Name}", object), object);
+        this.${relName}.put(getMapKey("${rel.Name}", object), object);
     }
+
     public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})
object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
+        } else if (this.$relName == null) {
         	throw new RuntimeException("Map relationships cannot be accessed for transient objects");
       
         }
 
-        this.${rel.Name}.remove(getMapKey("${rel.Name}", object));
+        this.${relName}.remove(getMapKey("${rel.Name}", object));
     }
+
 #else
     public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})
object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
+        } else if (this.$relName == null) {
+        	this.$relName = new PersistentObjectList(this, "${rel.Name}");
 		}
 
-        this.${rel.Name}.add(object);
+        this.${relName}.add(object);
     }
+
     public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})
object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
+        } else if (this.$relName == null) {
+        	this.$relName = new PersistentObjectList(this, "${rel.Name}");
 		}
 
-        this.${rel.Name}.remove(object);
+        this.${relName}.remove(object);
     }
+
 #end
 #end
 #else
     public $importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) get${stringUtils.capitalized($rel.Name)}()
{
         if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	this.$rel.Name = new PersistentObjectHolder(this, "$rel.Name");
+            objectContext.prepareForAccess(this, "$rel.Name", true);
+        } else if (this.$relName == null) {
+        	this.$relName = new PersistentObjectHolder(this, "$rel.Name");
 		}
 
-        return ($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})) ${rel.Name}.getValue();
+        return ($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})) ${relName}.getValue();
     }
+
 #if ( !${object.isReadOnly()} && !$rel.ReadOnly )
-    public void set${stringUtils.capitalized($rel.Name)}(${importUtils.formatJavaType($rel.TargetEntity.ClientClassName)}
$stringUtils.formatVariableName(${rel.Name})) {
+    public void set${stringUtils.capitalized($rel.Name)}(${importUtils.formatJavaType($rel.TargetEntity.ClientClassName)}
$relName) {
         if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	this.$rel.Name = new PersistentObjectHolder(this, "$rel.Name");
+            objectContext.prepareForAccess(this, "$rel.Name", true);
+            objectContext.propertyChanged(this, "$rel.Name", this.${relName}.getValueDirectly(),
$relName);
+        } else if (this.$relName == null) {
+        	this.$relName = new PersistentObjectHolder(this, "$rel.Name");
 		}
 
-        // note how we notify ObjectContext of change BEFORE the object is actually
-        // changed... this is needed to take a valid current snapshot
-        Object oldValue = this.${rel.Name}.getValueDirectly();
-        if (objectContext != null) {
-        	objectContext.propertyChanged(this, "$rel.Name", oldValue, $stringUtils.formatVariableName(${rel.Name}));
-        }
-        
-        this.${stringUtils.formatVariableName($rel.Name)}.setValue(${stringUtils.formatVariableName($rel.Name)});
+        this.${relName}.setValue($relName);
     }
+
 #end
 #end
-
 #end
 ##callback methods
 #foreach( $cbname in ${entityUtils.callbackNames})

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-crypto/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-crypto/pom.xml b/cayenne-crypto/pom.xml
index 5255e43..6dd01f2 100644
--- a/cayenne-crypto/pom.xml
+++ b/cayenne-crypto/pom.xml
@@ -88,6 +88,7 @@
 					<map>${project.basedir}/src/test/resources/datamap.map.xml</map>
 					<destDir>${project.basedir}/src/test/java</destDir>
 					<superPkg>org.apache.cayenne.crypto.db.auto</superPkg>
+					<force>true</force>
 				</configuration>
 				<executions>
 					<execution>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table1.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table1.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table1.java
index 3c773f5..bf34752 100644
--- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table1.java
+++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table1.java
@@ -24,9 +24,9 @@ public abstract class _Table1 extends BaseDataObject {
     public static final Property<Integer> PLAIN_INT = Property.create("plainInt", Integer.class);
     public static final Property<String> PLAIN_STRING = Property.create("plainString",
String.class);
 
-    protected int cryptoInt;
+    protected Integer cryptoInt;
     protected String cryptoString;
-    protected int plainInt;
+    protected Integer plainInt;
     protected String plainString;
 
 
@@ -37,7 +37,10 @@ public abstract class _Table1 extends BaseDataObject {
 
     public int getCryptoInt() {
         beforePropertyRead("cryptoInt");
-        return cryptoInt;
+        if(this.cryptoInt == null) {
+            return 0;
+        }
+        return this.cryptoInt;
     }
 
     public void setCryptoString(String cryptoString) {
@@ -47,7 +50,7 @@ public abstract class _Table1 extends BaseDataObject {
 
     public String getCryptoString() {
         beforePropertyRead("cryptoString");
-        return cryptoString;
+        return this.cryptoString;
     }
 
     public void setPlainInt(int plainInt) {
@@ -57,7 +60,10 @@ public abstract class _Table1 extends BaseDataObject {
 
     public int getPlainInt() {
         beforePropertyRead("plainInt");
-        return plainInt;
+        if(this.plainInt == null) {
+            return 0;
+        }
+        return this.plainInt;
     }
 
     public void setPlainString(String plainString) {
@@ -67,7 +73,7 @@ public abstract class _Table1 extends BaseDataObject {
 
     public String getPlainString() {
         beforePropertyRead("plainString");
-        return plainString;
+        return this.plainString;
     }
 
     @Override
@@ -98,13 +104,13 @@ public abstract class _Table1 extends BaseDataObject {
 
         switch (propName) {
             case "cryptoInt":
-                this.cryptoInt = val == null ? 0 : (Integer)val;
+                this.cryptoInt = (Integer)val;
                 break;
             case "cryptoString":
                 this.cryptoString = (String)val;
                 break;
             case "plainInt":
-                this.plainInt = val == null ? 0 : (Integer)val;
+                this.plainInt = (Integer)val;
                 break;
             case "plainString":
                 this.plainString = (String)val;
@@ -125,19 +131,19 @@ public abstract class _Table1 extends BaseDataObject {
     @Override
     protected void writeState(ObjectOutputStream out) throws IOException {
         super.writeState(out);
-        out.writeInt(cryptoInt);
-        out.writeObject(cryptoString);
-        out.writeInt(plainInt);
-        out.writeObject(plainString);
+        out.writeObject(this.cryptoInt);
+        out.writeObject(this.cryptoString);
+        out.writeObject(this.plainInt);
+        out.writeObject(this.plainString);
     }
 
     @Override
     protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException
{
         super.readState(in);
-        cryptoInt = in.readInt();
-        cryptoString = (String)in.readObject();
-        plainInt = in.readInt();
-        plainString = (String)in.readObject();
+        this.cryptoInt = (Integer)in.readObject();
+        this.cryptoString = (String)in.readObject();
+        this.plainInt = (Integer)in.readObject();
+        this.plainString = (String)in.readObject();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table2.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table2.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table2.java
index c10987e..5d0e518 100644
--- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table2.java
+++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table2.java
@@ -33,7 +33,7 @@ public abstract class _Table2 extends BaseDataObject {
 
     public byte[] getCryptoBytes() {
         beforePropertyRead("cryptoBytes");
-        return cryptoBytes;
+        return this.cryptoBytes;
     }
 
     public void setPlainBytes(byte[] plainBytes) {
@@ -43,7 +43,7 @@ public abstract class _Table2 extends BaseDataObject {
 
     public byte[] getPlainBytes() {
         beforePropertyRead("plainBytes");
-        return plainBytes;
+        return this.plainBytes;
     }
 
     @Override
@@ -91,15 +91,15 @@ public abstract class _Table2 extends BaseDataObject {
     @Override
     protected void writeState(ObjectOutputStream out) throws IOException {
         super.writeState(out);
-        out.writeObject(cryptoBytes);
-        out.writeObject(plainBytes);
+        out.writeObject(this.cryptoBytes);
+        out.writeObject(this.plainBytes);
     }
 
     @Override
     protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException
{
         super.readState(in);
-        cryptoBytes = (byte[])in.readObject();
-        plainBytes = (byte[])in.readObject();
+        this.cryptoBytes = (byte[])in.readObject();
+        this.plainBytes = (byte[])in.readObject();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table3.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table3.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table3.java
index 9e0d027..ce3913d 100644
--- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table3.java
+++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table3.java
@@ -31,7 +31,7 @@ public abstract class _Table3 extends BaseDataObject {
 
     public String getCryptoString() {
         beforePropertyRead("cryptoString");
-        return cryptoString;
+        return this.cryptoString;
     }
 
     @Override
@@ -74,13 +74,13 @@ public abstract class _Table3 extends BaseDataObject {
     @Override
     protected void writeState(ObjectOutputStream out) throws IOException {
         super.writeState(out);
-        out.writeObject(cryptoString);
+        out.writeObject(this.cryptoString);
     }
 
     @Override
     protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException
{
         super.readState(in);
-        cryptoString = (String)in.readObject();
+        this.cryptoString = (String)in.readObject();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table4.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table4.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table4.java
index 5563c63..779c530 100644
--- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table4.java
+++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table4.java
@@ -22,7 +22,7 @@ public abstract class _Table4 extends BaseDataObject {
     public static final Property<Integer> PLAIN_INT = Property.create("plainInt", Integer.class);
     public static final Property<String> PLAIN_STRING = Property.create("plainString",
String.class);
 
-    protected int plainInt;
+    protected Integer plainInt;
     protected String plainString;
 
 
@@ -33,7 +33,10 @@ public abstract class _Table4 extends BaseDataObject {
 
     public int getPlainInt() {
         beforePropertyRead("plainInt");
-        return plainInt;
+        if(this.plainInt == null) {
+            return 0;
+        }
+        return this.plainInt;
     }
 
     public void setPlainString(String plainString) {
@@ -43,7 +46,7 @@ public abstract class _Table4 extends BaseDataObject {
 
     public String getPlainString() {
         beforePropertyRead("plainString");
-        return plainString;
+        return this.plainString;
     }
 
     @Override
@@ -70,7 +73,7 @@ public abstract class _Table4 extends BaseDataObject {
 
         switch (propName) {
             case "plainInt":
-                this.plainInt = val == null ? 0 : (Integer)val;
+                this.plainInt = (Integer)val;
                 break;
             case "plainString":
                 this.plainString = (String)val;
@@ -91,15 +94,15 @@ public abstract class _Table4 extends BaseDataObject {
     @Override
     protected void writeState(ObjectOutputStream out) throws IOException {
         super.writeState(out);
-        out.writeInt(plainInt);
-        out.writeObject(plainString);
+        out.writeObject(this.plainInt);
+        out.writeObject(this.plainString);
     }
 
     @Override
     protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException
{
         super.readState(in);
-        plainInt = in.readInt();
-        plainString = (String)in.readObject();
+        this.plainInt = (Integer)in.readObject();
+        this.plainString = (String)in.readObject();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table5.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table5.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table5.java
index 44aa168..0fec43f 100644
--- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table5.java
+++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table5.java
@@ -23,9 +23,9 @@ public abstract class _Table5 extends BaseDataObject {
     public static final Property<Integer> CRYPTO_INT3 = Property.create("cryptoInt3",
Integer.class);
     public static final Property<Integer> CRYPTO_INT4 = Property.create("cryptoInt4",
Integer.class);
 
-    protected int cryptoInt1;
-    protected int cryptoInt3;
-    protected int cryptoInt4;
+    protected Integer cryptoInt1;
+    protected Integer cryptoInt3;
+    protected Integer cryptoInt4;
 
 
     public void setCryptoInt1(int cryptoInt1) {
@@ -35,7 +35,10 @@ public abstract class _Table5 extends BaseDataObject {
 
     public int getCryptoInt1() {
         beforePropertyRead("cryptoInt1");
-        return cryptoInt1;
+        if(this.cryptoInt1 == null) {
+            return 0;
+        }
+        return this.cryptoInt1;
     }
 
     public void setCryptoInt3(int cryptoInt3) {
@@ -45,7 +48,10 @@ public abstract class _Table5 extends BaseDataObject {
 
     public int getCryptoInt3() {
         beforePropertyRead("cryptoInt3");
-        return cryptoInt3;
+        if(this.cryptoInt3 == null) {
+            return 0;
+        }
+        return this.cryptoInt3;
     }
 
     public void setCryptoInt4(int cryptoInt4) {
@@ -55,7 +61,10 @@ public abstract class _Table5 extends BaseDataObject {
 
     public int getCryptoInt4() {
         beforePropertyRead("cryptoInt4");
-        return cryptoInt4;
+        if(this.cryptoInt4 == null) {
+            return 0;
+        }
+        return this.cryptoInt4;
     }
 
     @Override
@@ -84,13 +93,13 @@ public abstract class _Table5 extends BaseDataObject {
 
         switch (propName) {
             case "cryptoInt1":
-                this.cryptoInt1 = val == null ? 0 : (Integer)val;
+                this.cryptoInt1 = (Integer)val;
                 break;
             case "cryptoInt3":
-                this.cryptoInt3 = val == null ? 0 : (Integer)val;
+                this.cryptoInt3 = (Integer)val;
                 break;
             case "cryptoInt4":
-                this.cryptoInt4 = val == null ? 0 : (Integer)val;
+                this.cryptoInt4 = (Integer)val;
                 break;
             default:
                 super.writePropertyDirectly(propName, val);
@@ -108,17 +117,17 @@ public abstract class _Table5 extends BaseDataObject {
     @Override
     protected void writeState(ObjectOutputStream out) throws IOException {
         super.writeState(out);
-        out.writeInt(cryptoInt1);
-        out.writeInt(cryptoInt3);
-        out.writeInt(cryptoInt4);
+        out.writeObject(this.cryptoInt1);
+        out.writeObject(this.cryptoInt3);
+        out.writeObject(this.cryptoInt4);
     }
 
     @Override
     protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException
{
         super.readState(in);
-        cryptoInt1 = in.readInt();
-        cryptoInt3 = in.readInt();
-        cryptoInt4 = in.readInt();
+        this.cryptoInt1 = (Integer)in.readObject();
+        this.cryptoInt3 = (Integer)in.readObject();
+        this.cryptoInt4 = (Integer)in.readObject();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table6.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table6.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table6.java
index 61db882..76cee43 100644
--- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table6.java
+++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/db/auto/_Table6.java
@@ -22,8 +22,8 @@ public abstract class _Table6 extends BaseDataObject {
     public static final Property<Long> CRYPTO_INT1 = Property.create("cryptoInt1",
Long.class);
     public static final Property<Integer> CRYPTO_INT4 = Property.create("cryptoInt4",
Integer.class);
 
-    protected long cryptoInt1;
-    protected int cryptoInt4;
+    protected Long cryptoInt1;
+    protected Integer cryptoInt4;
 
 
     public void setCryptoInt1(long cryptoInt1) {
@@ -33,7 +33,10 @@ public abstract class _Table6 extends BaseDataObject {
 
     public long getCryptoInt1() {
         beforePropertyRead("cryptoInt1");
-        return cryptoInt1;
+        if(this.cryptoInt1 == null) {
+            return 0;
+        }
+        return this.cryptoInt1;
     }
 
     public void setCryptoInt4(int cryptoInt4) {
@@ -43,7 +46,10 @@ public abstract class _Table6 extends BaseDataObject {
 
     public int getCryptoInt4() {
         beforePropertyRead("cryptoInt4");
-        return cryptoInt4;
+        if(this.cryptoInt4 == null) {
+            return 0;
+        }
+        return this.cryptoInt4;
     }
 
     @Override
@@ -70,10 +76,10 @@ public abstract class _Table6 extends BaseDataObject {
 
         switch (propName) {
             case "cryptoInt1":
-                this.cryptoInt1 = val == null ? 0 : (Long)val;
+                this.cryptoInt1 = (Long)val;
                 break;
             case "cryptoInt4":
-                this.cryptoInt4 = val == null ? 0 : (Integer)val;
+                this.cryptoInt4 = (Integer)val;
                 break;
             default:
                 super.writePropertyDirectly(propName, val);
@@ -91,15 +97,15 @@ public abstract class _Table6 extends BaseDataObject {
     @Override
     protected void writeState(ObjectOutputStream out) throws IOException {
         super.writeState(out);
-        out.writeLong(cryptoInt1);
-        out.writeInt(cryptoInt4);
+        out.writeObject(this.cryptoInt1);
+        out.writeObject(this.cryptoInt4);
     }
 
     @Override
     protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException
{
         super.readState(in);
-        cryptoInt1 = in.readLong();
-        cryptoInt4 = in.readInt();
+        this.cryptoInt1 = (Long)in.readObject();
+        this.cryptoInt4 = (Integer)in.readObject();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-protostuff/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-protostuff/pom.xml b/cayenne-protostuff/pom.xml
index 1e0577a..5ec532c 100644
--- a/cayenne-protostuff/pom.xml
+++ b/cayenne-protostuff/pom.xml
@@ -109,6 +109,7 @@
                     <map>${project.basedir}/src/test/resources/protostuff.map.xml</map>
                     <destDir>${project.basedir}/src/test/java</destDir>
                     <client>true</client>
+                    <force>true</force>
                 </configuration>
                 <executions>
                     <execution>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable1.java
----------------------------------------------------------------------
diff --git a/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable1.java
b/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable1.java
index e7178e0..7fca1de 100644
--- a/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable1.java
+++ b/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable1.java
@@ -47,7 +47,7 @@ public abstract class _ClientMtTable1 extends PersistentObject {
             objectContext.prepareForAccess(this, "dateAttribute", false);
             objectContext.propertyChanged(this, "dateAttribute", this.dateAttribute, dateAttribute);
         }
-        
+
         this.dateAttribute = dateAttribute;
     }
 
@@ -64,7 +64,7 @@ public abstract class _ClientMtTable1 extends PersistentObject {
             objectContext.prepareForAccess(this, "globalAttribute", false);
             objectContext.propertyChanged(this, "globalAttribute", this.globalAttribute,
globalAttribute);
         }
-        
+
         this.globalAttribute = globalAttribute;
     }
 
@@ -81,7 +81,7 @@ public abstract class _ClientMtTable1 extends PersistentObject {
             objectContext.prepareForAccess(this, "oldDateAttribute", false);
             objectContext.propertyChanged(this, "oldDateAttribute", this.oldDateAttribute,
oldDateAttribute);
         }
-        
+
         this.oldDateAttribute = oldDateAttribute;
     }
 
@@ -98,7 +98,7 @@ public abstract class _ClientMtTable1 extends PersistentObject {
             objectContext.prepareForAccess(this, "serverAttribute", false);
             objectContext.propertyChanged(this, "serverAttribute", this.serverAttribute,
serverAttribute);
         }
-        
+
         this.serverAttribute = serverAttribute;
     }
 
@@ -115,7 +115,7 @@ public abstract class _ClientMtTable1 extends PersistentObject {
             objectContext.prepareForAccess(this, "timeAttribute", false);
             objectContext.propertyChanged(this, "timeAttribute", this.timeAttribute, timeAttribute);
         }
-        
+
         this.timeAttribute = timeAttribute;
     }
 
@@ -132,7 +132,7 @@ public abstract class _ClientMtTable1 extends PersistentObject {
             objectContext.prepareForAccess(this, "timestampAttribute", false);
             objectContext.propertyChanged(this, "timestampAttribute", this.timestampAttribute,
timestampAttribute);
         }
-        
+
         this.timestampAttribute = timestampAttribute;
     }
 
@@ -165,4 +165,5 @@ public abstract class _ClientMtTable1 extends PersistentObject {
 
         this.table2Array.remove(object);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e591f4d1/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable2.java
----------------------------------------------------------------------
diff --git a/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable2.java
b/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable2.java
index a6c8c37..a3cb86c 100644
--- a/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable2.java
+++ b/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/persistent/auto/_ClientMtTable2.java
@@ -32,7 +32,7 @@ public abstract class _ClientMtTable2 extends PersistentObject {
             objectContext.prepareForAccess(this, "globalAttribute", false);
             objectContext.propertyChanged(this, "globalAttribute", this.globalAttribute,
globalAttribute);
         }
-        
+
         this.globalAttribute = globalAttribute;
     }
 
@@ -53,7 +53,8 @@ public abstract class _ClientMtTable2 extends PersistentObject {
         } else if (this.table1 == null) {
         	this.table1 = new PersistentObjectHolder(this, "table1");
 		}
-        
+
         this.table1.setValue(table1);
     }
+
 }


Mime
View raw message