cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/4] cayenne git commit: CAY-2467 New type-aware Property API - update client cgen templates - update client tests
Date Fri, 28 Dec 2018 12:38:22 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 56b64c35e -> 2cca2445f


http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
index d4ed6aa..0dfd941 100644
--- a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
+++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
@@ -1,9 +1,14 @@
 package org.apache.cayenne.tutorial.persistent.auto;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.List;
 
-import org.apache.cayenne.CayenneDataObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.BaseDataObject;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.Painting;
 
 /**
@@ -12,32 +17,96 @@ import org.apache.cayenne.tutorial.persistent.Painting;
  * since it may be overwritten next time code is regenerated.
  * If you need to make any customizations, please use subclass.
  */
-public abstract class _Gallery extends CayenneDataObject {
+public abstract class _Gallery extends BaseDataObject {
 
     private static final long serialVersionUID = 1L; 
 
     public static final String ID_PK_COLUMN = "ID";
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
+
+    protected String name;
+
+    protected Object paintings;
 
     public void setName(String name) {
-        writeProperty("name", name);
+        beforePropertyWrite("name", this.name, name);
+        this.name = name;
     }
+
     public String getName() {
-        return (String)readProperty("name");
+        beforePropertyRead("name");
+        return this.name;
     }
 
     public void addToPaintings(Painting obj) {
         addToManyTarget("paintings", obj, true);
     }
+
     public void removeFromPaintings(Painting obj) {
         removeToManyTarget("paintings", obj, true);
     }
+
     @SuppressWarnings("unchecked")
     public List<Painting> getPaintings() {
         return (List<Painting>)readProperty("paintings");
     }
 
+    @Override
+    public Object readPropertyDirectly(String propName) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch(propName) {
+            case "name":
+                return this.name;
+            case "paintings":
+                return this.paintings;
+            default:
+                return super.readPropertyDirectly(propName);
+        }
+    }
+
+    @Override
+    public void writePropertyDirectly(String propName, Object val) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch (propName) {
+            case "name":
+                this.name = (String)val;
+                break;
+            case "paintings":
+                this.paintings = val;
+                break;
+            default:
+                super.writePropertyDirectly(propName, val);
+        }
+    }
+
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        writeSerialized(out);
+    }
+
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        readSerialized(in);
+    }
+
+    @Override
+    protected void writeState(ObjectOutputStream out) throws IOException {
+        super.writeState(out);
+        out.writeObject(this.name);
+        out.writeObject(this.paintings);
+    }
+
+    @Override
+    protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        super.readState(in);
+        this.name = (String)in.readObject();
+        this.paintings = in.readObject();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
index 0c39d79..e15e25f 100644
--- a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
+++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
@@ -1,7 +1,13 @@
 package org.apache.cayenne.tutorial.persistent.auto;
 
-import org.apache.cayenne.CayenneDataObject;
-import org.apache.cayenne.exp.Property;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.cayenne.BaseDataObject;
+import org.apache.cayenne.exp.property.EntityProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.Artist;
 import org.apache.cayenne.tutorial.persistent.Gallery;
 
@@ -11,21 +17,29 @@ import org.apache.cayenne.tutorial.persistent.Gallery;
  * since it may be overwritten next time code is regenerated.
  * If you need to make any customizations, please use subclass.
  */
-public abstract class _Painting extends CayenneDataObject {
+public abstract class _Painting extends BaseDataObject {
 
     private static final long serialVersionUID = 1L; 
 
     public static final String ID_PK_COLUMN = "ID";
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<Artist> ARTIST = Property.create("artist", Artist.class);
-    public static final Property<Gallery> GALLERY = Property.create("gallery", Gallery.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final EntityProperty<org.apache.cayenne.tutorial.persistent.Artist> ARTIST = PropertyFactory.createEntity("artist", org.apache.cayenne.tutorial.persistent.Artist.class);
+    public static final EntityProperty<org.apache.cayenne.tutorial.persistent.Gallery> GALLERY = PropertyFactory.createEntity("gallery", org.apache.cayenne.tutorial.persistent.Gallery.class);
+
+    protected String name;
+
+    protected Object artist;
+    protected Object gallery;
 
     public void setName(String name) {
-        writeProperty("name", name);
+        beforePropertyWrite("name", this.name, name);
+        this.name = name;
     }
+
     public String getName() {
-        return (String)readProperty("name");
+        beforePropertyRead("name");
+        return this.name;
     }
 
     public void setArtist(Artist artist) {
@@ -36,7 +50,6 @@ public abstract class _Painting extends CayenneDataObject {
         return (Artist)readProperty("artist");
     }
 
-
     public void setGallery(Gallery gallery) {
         setToOneTarget("gallery", gallery, true);
     }
@@ -45,5 +58,67 @@ public abstract class _Painting extends CayenneDataObject {
         return (Gallery)readProperty("gallery");
     }
 
+    @Override
+    public Object readPropertyDirectly(String propName) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch(propName) {
+            case "name":
+                return this.name;
+            case "artist":
+                return this.artist;
+            case "gallery":
+                return this.gallery;
+            default:
+                return super.readPropertyDirectly(propName);
+        }
+    }
+
+    @Override
+    public void writePropertyDirectly(String propName, Object val) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch (propName) {
+            case "name":
+                this.name = (String)val;
+                break;
+            case "artist":
+                this.artist = val;
+                break;
+            case "gallery":
+                this.gallery = val;
+                break;
+            default:
+                super.writePropertyDirectly(propName, val);
+        }
+    }
+
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        writeSerialized(out);
+    }
+
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        readSerialized(in);
+    }
+
+    @Override
+    protected void writeState(ObjectOutputStream out) throws IOException {
+        super.writeState(out);
+        out.writeObject(this.name);
+        out.writeObject(this.artist);
+        out.writeObject(this.gallery);
+    }
+
+    @Override
+    protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        super.readState(in);
+        this.name = (String)in.readObject();
+        this.artist = in.readObject();
+        this.gallery = in.readObject();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java
index b478b8d..052709b 100644
--- a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java
+++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java
@@ -4,7 +4,10 @@ import java.time.LocalDate;
 import java.util.List;
 
 import org.apache.cayenne.PersistentObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.DateProperty;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.client.Painting;
 import org.apache.cayenne.util.PersistentObjectList;
 
@@ -15,9 +18,9 @@ import org.apache.cayenne.util.PersistentObjectList;
  */
 public abstract class _Artist extends PersistentObject {
 
-    public static final Property<LocalDate> DATE_OF_BIRTH = Property.create("dateOfBirth", LocalDate.class);
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final DateProperty<LocalDate> DATE_OF_BIRTH = PropertyFactory.createDate("dateOfBirth", LocalDate.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
 
     protected LocalDate dateOfBirth;
     protected String name;
@@ -30,17 +33,13 @@ public abstract class _Artist extends PersistentObject {
 
         return dateOfBirth;
     }
+
     public void setDateOfBirth(LocalDate dateOfBirth) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "dateOfBirth", false);
+            objectContext.propertyChanged(this, "dateOfBirth", this.dateOfBirth, dateOfBirth);
         }
 
-        Object oldValue = this.dateOfBirth;
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "dateOfBirth", oldValue, dateOfBirth);
-        }
-        
         this.dateOfBirth = dateOfBirth;
     }
 
@@ -51,17 +50,13 @@ public abstract class _Artist extends PersistentObject {
 
         return name;
     }
+
     public void setName(String name) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "name", false);
+            objectContext.propertyChanged(this, "name", this.name, name);
         }
 
-        Object oldValue = this.name;
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "name", oldValue, name);
-        }
-        
         this.name = name;
     }
 
@@ -69,25 +64,27 @@ public abstract class _Artist extends PersistentObject {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         return paintings;
     }
+
     public void addToPaintings(Painting object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         this.paintings.add(object);
     }
+
     public void removeFromPaintings(Painting object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         this.paintings.remove(object);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java
index 7c59c64..57ccb07 100644
--- a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java
+++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java
@@ -3,7 +3,9 @@ package org.apache.cayenne.tutorial.persistent.client.auto;
 import java.util.List;
 
 import org.apache.cayenne.PersistentObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.client.Painting;
 import org.apache.cayenne.util.PersistentObjectList;
 
@@ -14,8 +16,8 @@ import org.apache.cayenne.util.PersistentObjectList;
  */
 public abstract class _Gallery extends PersistentObject {
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
 
     protected String name;
     protected List<Painting> paintings;
@@ -27,17 +29,13 @@ public abstract class _Gallery extends PersistentObject {
 
         return name;
     }
+
     public void setName(String name) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "name", false);
+            objectContext.propertyChanged(this, "name", this.name, name);
         }
 
-        Object oldValue = this.name;
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "name", oldValue, name);
-        }
-        
         this.name = name;
     }
 
@@ -45,25 +43,27 @@ public abstract class _Gallery extends PersistentObject {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         return paintings;
     }
+
     public void addToPaintings(Painting object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         this.paintings.add(object);
     }
+
     public void removeFromPaintings(Painting object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         this.paintings.remove(object);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java
index ab004f9..ec9511a 100644
--- a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java
+++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java
@@ -2,7 +2,9 @@ package org.apache.cayenne.tutorial.persistent.client.auto;
 
 import org.apache.cayenne.PersistentObject;
 import org.apache.cayenne.ValueHolder;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.EntityProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.client.Artist;
 import org.apache.cayenne.tutorial.persistent.client.Gallery;
 import org.apache.cayenne.util.PersistentObjectHolder;
@@ -14,13 +16,13 @@ import org.apache.cayenne.util.PersistentObjectHolder;
  */
 public abstract class _Painting extends PersistentObject {
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<Artist> ARTIST = Property.create("artist", Artist.class);
-    public static final Property<Gallery> GALLERY = Property.create("gallery", Gallery.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final EntityProperty<Artist> ARTIST = PropertyFactory.createEntity("artist", Artist.class);
+    public static final EntityProperty<Gallery> GALLERY = PropertyFactory.createEntity("gallery", Gallery.class);
 
     protected String name;
-    protected ValueHolder artist;
-    protected ValueHolder gallery;
+    protected ValueHolder<Artist> artist;
+    protected ValueHolder<Gallery> gallery;
 
     public String getName() {
         if(objectContext != null) {
@@ -29,17 +31,13 @@ public abstract class _Painting extends PersistentObject {
 
         return name;
     }
+
     public void setName(String name) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "name", false);
+            objectContext.propertyChanged(this, "name", this.name, name);
         }
 
-        Object oldValue = this.name;
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "name", oldValue, name);
-        }
-        
         this.name = name;
     }
 
@@ -47,25 +45,19 @@ public abstract class _Painting extends PersistentObject {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "artist", true);
         } else if (this.artist == null) {
-        	this.artist = new PersistentObjectHolder(this, "artist");
+        	this.artist = new PersistentObjectHolder<>(this, "artist");
 		}
 
-        return (Artist) artist.getValue();
+        return artist.getValue();
     }
+
     public void setArtist(Artist artist) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "artist", true);
         } else if (this.artist == null) {
-        	this.artist = new PersistentObjectHolder(this, "artist");
+        	this.artist = new PersistentObjectHolder<>(this, "artist");
 		}
 
-        // 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.artist.getValueDirectly();
-        if (objectContext != null) {
-        	objectContext.propertyChanged(this, "artist", oldValue, artist);
-        }
-        
         this.artist.setValue(artist);
     }
 
@@ -73,25 +65,19 @@ public abstract class _Painting extends PersistentObject {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "gallery", true);
         } else if (this.gallery == null) {
-        	this.gallery = new PersistentObjectHolder(this, "gallery");
+        	this.gallery = new PersistentObjectHolder<>(this, "gallery");
 		}
 
-        return (Gallery) gallery.getValue();
+        return gallery.getValue();
     }
+
     public void setGallery(Gallery gallery) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "gallery", true);
         } else if (this.gallery == null) {
-        	this.gallery = new PersistentObjectHolder(this, "gallery");
+        	this.gallery = new PersistentObjectHolder<>(this, "gallery");
 		}
 
-        // 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.gallery.getValueDirectly();
-        if (objectContext != null) {
-        	objectContext.propertyChanged(this, "gallery", oldValue, gallery);
-        }
-        
         this.gallery.setValue(gallery);
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java
index 147f9f7..5ff7823 100644
--- a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java
+++ b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java
@@ -1,10 +1,16 @@
 package org.apache.cayenne.tutorial.persistent.auto;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.time.LocalDate;
 import java.util.List;
 
-import org.apache.cayenne.CayenneDataObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.BaseDataObject;
+import org.apache.cayenne.exp.property.DateProperty;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.Painting;
 
 /**
@@ -13,40 +19,115 @@ import org.apache.cayenne.tutorial.persistent.Painting;
  * since it may be overwritten next time code is regenerated.
  * If you need to make any customizations, please use subclass.
  */
-public abstract class _Artist extends CayenneDataObject {
+public abstract class _Artist extends BaseDataObject {
 
     private static final long serialVersionUID = 1L; 
 
     public static final String ID_PK_COLUMN = "ID";
 
-    public static final Property<LocalDate> DATE_OF_BIRTH = Property.create("dateOfBirth", LocalDate.class);
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final DateProperty<LocalDate> DATE_OF_BIRTH = PropertyFactory.createDate("dateOfBirth", LocalDate.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
+
+    protected LocalDate dateOfBirth;
+    protected String name;
+
+    protected Object paintings;
 
     public void setDateOfBirth(LocalDate dateOfBirth) {
-        writeProperty("dateOfBirth", dateOfBirth);
+        beforePropertyWrite("dateOfBirth", this.dateOfBirth, dateOfBirth);
+        this.dateOfBirth = dateOfBirth;
     }
+
     public LocalDate getDateOfBirth() {
-        return (LocalDate)readProperty("dateOfBirth");
+        beforePropertyRead("dateOfBirth");
+        return this.dateOfBirth;
     }
 
     public void setName(String name) {
-        writeProperty("name", name);
+        beforePropertyWrite("name", this.name, name);
+        this.name = name;
     }
+
     public String getName() {
-        return (String)readProperty("name");
+        beforePropertyRead("name");
+        return this.name;
     }
 
     public void addToPaintings(Painting obj) {
         addToManyTarget("paintings", obj, true);
     }
+
     public void removeFromPaintings(Painting obj) {
         removeToManyTarget("paintings", obj, true);
     }
+
     @SuppressWarnings("unchecked")
     public List<Painting> getPaintings() {
         return (List<Painting>)readProperty("paintings");
     }
 
+    @Override
+    public Object readPropertyDirectly(String propName) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch(propName) {
+            case "dateOfBirth":
+                return this.dateOfBirth;
+            case "name":
+                return this.name;
+            case "paintings":
+                return this.paintings;
+            default:
+                return super.readPropertyDirectly(propName);
+        }
+    }
+
+    @Override
+    public void writePropertyDirectly(String propName, Object val) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch (propName) {
+            case "dateOfBirth":
+                this.dateOfBirth = (LocalDate)val;
+                break;
+            case "name":
+                this.name = (String)val;
+                break;
+            case "paintings":
+                this.paintings = val;
+                break;
+            default:
+                super.writePropertyDirectly(propName, val);
+        }
+    }
+
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        writeSerialized(out);
+    }
+
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        readSerialized(in);
+    }
+
+    @Override
+    protected void writeState(ObjectOutputStream out) throws IOException {
+        super.writeState(out);
+        out.writeObject(this.dateOfBirth);
+        out.writeObject(this.name);
+        out.writeObject(this.paintings);
+    }
+
+    @Override
+    protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        super.readState(in);
+        this.dateOfBirth = (LocalDate)in.readObject();
+        this.name = (String)in.readObject();
+        this.paintings = in.readObject();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
index d4ed6aa..0dfd941 100644
--- a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
+++ b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
@@ -1,9 +1,14 @@
 package org.apache.cayenne.tutorial.persistent.auto;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.List;
 
-import org.apache.cayenne.CayenneDataObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.BaseDataObject;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.Painting;
 
 /**
@@ -12,32 +17,96 @@ import org.apache.cayenne.tutorial.persistent.Painting;
  * since it may be overwritten next time code is regenerated.
  * If you need to make any customizations, please use subclass.
  */
-public abstract class _Gallery extends CayenneDataObject {
+public abstract class _Gallery extends BaseDataObject {
 
     private static final long serialVersionUID = 1L; 
 
     public static final String ID_PK_COLUMN = "ID";
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
+
+    protected String name;
+
+    protected Object paintings;
 
     public void setName(String name) {
-        writeProperty("name", name);
+        beforePropertyWrite("name", this.name, name);
+        this.name = name;
     }
+
     public String getName() {
-        return (String)readProperty("name");
+        beforePropertyRead("name");
+        return this.name;
     }
 
     public void addToPaintings(Painting obj) {
         addToManyTarget("paintings", obj, true);
     }
+
     public void removeFromPaintings(Painting obj) {
         removeToManyTarget("paintings", obj, true);
     }
+
     @SuppressWarnings("unchecked")
     public List<Painting> getPaintings() {
         return (List<Painting>)readProperty("paintings");
     }
 
+    @Override
+    public Object readPropertyDirectly(String propName) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch(propName) {
+            case "name":
+                return this.name;
+            case "paintings":
+                return this.paintings;
+            default:
+                return super.readPropertyDirectly(propName);
+        }
+    }
+
+    @Override
+    public void writePropertyDirectly(String propName, Object val) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch (propName) {
+            case "name":
+                this.name = (String)val;
+                break;
+            case "paintings":
+                this.paintings = val;
+                break;
+            default:
+                super.writePropertyDirectly(propName, val);
+        }
+    }
+
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        writeSerialized(out);
+    }
+
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        readSerialized(in);
+    }
+
+    @Override
+    protected void writeState(ObjectOutputStream out) throws IOException {
+        super.writeState(out);
+        out.writeObject(this.name);
+        out.writeObject(this.paintings);
+    }
+
+    @Override
+    protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        super.readState(in);
+        this.name = (String)in.readObject();
+        this.paintings = in.readObject();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
index 0c39d79..e15e25f 100644
--- a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
+++ b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
@@ -1,7 +1,13 @@
 package org.apache.cayenne.tutorial.persistent.auto;
 
-import org.apache.cayenne.CayenneDataObject;
-import org.apache.cayenne.exp.Property;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.cayenne.BaseDataObject;
+import org.apache.cayenne.exp.property.EntityProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.Artist;
 import org.apache.cayenne.tutorial.persistent.Gallery;
 
@@ -11,21 +17,29 @@ import org.apache.cayenne.tutorial.persistent.Gallery;
  * since it may be overwritten next time code is regenerated.
  * If you need to make any customizations, please use subclass.
  */
-public abstract class _Painting extends CayenneDataObject {
+public abstract class _Painting extends BaseDataObject {
 
     private static final long serialVersionUID = 1L; 
 
     public static final String ID_PK_COLUMN = "ID";
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<Artist> ARTIST = Property.create("artist", Artist.class);
-    public static final Property<Gallery> GALLERY = Property.create("gallery", Gallery.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final EntityProperty<org.apache.cayenne.tutorial.persistent.Artist> ARTIST = PropertyFactory.createEntity("artist", org.apache.cayenne.tutorial.persistent.Artist.class);
+    public static final EntityProperty<org.apache.cayenne.tutorial.persistent.Gallery> GALLERY = PropertyFactory.createEntity("gallery", org.apache.cayenne.tutorial.persistent.Gallery.class);
+
+    protected String name;
+
+    protected Object artist;
+    protected Object gallery;
 
     public void setName(String name) {
-        writeProperty("name", name);
+        beforePropertyWrite("name", this.name, name);
+        this.name = name;
     }
+
     public String getName() {
-        return (String)readProperty("name");
+        beforePropertyRead("name");
+        return this.name;
     }
 
     public void setArtist(Artist artist) {
@@ -36,7 +50,6 @@ public abstract class _Painting extends CayenneDataObject {
         return (Artist)readProperty("artist");
     }
 
-
     public void setGallery(Gallery gallery) {
         setToOneTarget("gallery", gallery, true);
     }
@@ -45,5 +58,67 @@ public abstract class _Painting extends CayenneDataObject {
         return (Gallery)readProperty("gallery");
     }
 
+    @Override
+    public Object readPropertyDirectly(String propName) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch(propName) {
+            case "name":
+                return this.name;
+            case "artist":
+                return this.artist;
+            case "gallery":
+                return this.gallery;
+            default:
+                return super.readPropertyDirectly(propName);
+        }
+    }
+
+    @Override
+    public void writePropertyDirectly(String propName, Object val) {
+        if(propName == null) {
+            throw new IllegalArgumentException();
+        }
+
+        switch (propName) {
+            case "name":
+                this.name = (String)val;
+                break;
+            case "artist":
+                this.artist = val;
+                break;
+            case "gallery":
+                this.gallery = val;
+                break;
+            default:
+                super.writePropertyDirectly(propName, val);
+        }
+    }
+
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        writeSerialized(out);
+    }
+
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        readSerialized(in);
+    }
+
+    @Override
+    protected void writeState(ObjectOutputStream out) throws IOException {
+        super.writeState(out);
+        out.writeObject(this.name);
+        out.writeObject(this.artist);
+        out.writeObject(this.gallery);
+    }
+
+    @Override
+    protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        super.readState(in);
+        this.name = (String)in.readObject();
+        this.artist = in.readObject();
+        this.gallery = in.readObject();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java
index b478b8d..052709b 100644
--- a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java
+++ b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java
@@ -4,7 +4,10 @@ import java.time.LocalDate;
 import java.util.List;
 
 import org.apache.cayenne.PersistentObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.DateProperty;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.client.Painting;
 import org.apache.cayenne.util.PersistentObjectList;
 
@@ -15,9 +18,9 @@ import org.apache.cayenne.util.PersistentObjectList;
  */
 public abstract class _Artist extends PersistentObject {
 
-    public static final Property<LocalDate> DATE_OF_BIRTH = Property.create("dateOfBirth", LocalDate.class);
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final DateProperty<LocalDate> DATE_OF_BIRTH = PropertyFactory.createDate("dateOfBirth", LocalDate.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
 
     protected LocalDate dateOfBirth;
     protected String name;
@@ -30,17 +33,13 @@ public abstract class _Artist extends PersistentObject {
 
         return dateOfBirth;
     }
+
     public void setDateOfBirth(LocalDate dateOfBirth) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "dateOfBirth", false);
+            objectContext.propertyChanged(this, "dateOfBirth", this.dateOfBirth, dateOfBirth);
         }
 
-        Object oldValue = this.dateOfBirth;
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "dateOfBirth", oldValue, dateOfBirth);
-        }
-        
         this.dateOfBirth = dateOfBirth;
     }
 
@@ -51,17 +50,13 @@ public abstract class _Artist extends PersistentObject {
 
         return name;
     }
+
     public void setName(String name) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "name", false);
+            objectContext.propertyChanged(this, "name", this.name, name);
         }
 
-        Object oldValue = this.name;
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "name", oldValue, name);
-        }
-        
         this.name = name;
     }
 
@@ -69,25 +64,27 @@ public abstract class _Artist extends PersistentObject {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         return paintings;
     }
+
     public void addToPaintings(Painting object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         this.paintings.add(object);
     }
+
     public void removeFromPaintings(Painting object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         this.paintings.remove(object);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java
index 7c59c64..57ccb07 100644
--- a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java
+++ b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java
@@ -3,7 +3,9 @@ package org.apache.cayenne.tutorial.persistent.client.auto;
 import java.util.List;
 
 import org.apache.cayenne.PersistentObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.client.Painting;
 import org.apache.cayenne.util.PersistentObjectList;
 
@@ -14,8 +16,8 @@ import org.apache.cayenne.util.PersistentObjectList;
  */
 public abstract class _Gallery extends PersistentObject {
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
 
     protected String name;
     protected List<Painting> paintings;
@@ -27,17 +29,13 @@ public abstract class _Gallery extends PersistentObject {
 
         return name;
     }
+
     public void setName(String name) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "name", false);
+            objectContext.propertyChanged(this, "name", this.name, name);
         }
 
-        Object oldValue = this.name;
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "name", oldValue, name);
-        }
-        
         this.name = name;
     }
 
@@ -45,25 +43,27 @@ public abstract class _Gallery extends PersistentObject {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         return paintings;
     }
+
     public void addToPaintings(Painting object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         this.paintings.add(object);
     }
+
     public void removeFromPaintings(Painting object) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "paintings", true);
         } else if (this.paintings == null) {
-        	this.paintings = new PersistentObjectList(this, "paintings");
+        	this.paintings = new PersistentObjectList<>(this, "paintings");
 		}
 
         this.paintings.remove(object);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java
index 1671057..ec9511a 100644
--- a/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java
+++ b/tutorials/tutorial-rop-server/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java
@@ -2,7 +2,9 @@ package org.apache.cayenne.tutorial.persistent.client.auto;
 
 import org.apache.cayenne.PersistentObject;
 import org.apache.cayenne.ValueHolder;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.EntityProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.client.Artist;
 import org.apache.cayenne.tutorial.persistent.client.Gallery;
 import org.apache.cayenne.util.PersistentObjectHolder;
@@ -14,13 +16,13 @@ import org.apache.cayenne.util.PersistentObjectHolder;
  */
 public abstract class _Painting extends PersistentObject {
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<org.apache.cayenne.tutorial.persistent.Artist> ARTIST = Property.create("artist", org.apache.cayenne.tutorial.persistent.Artist.class);
-    public static final Property<org.apache.cayenne.tutorial.persistent.Gallery> GALLERY = Property.create("gallery", org.apache.cayenne.tutorial.persistent.Gallery.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final EntityProperty<Artist> ARTIST = PropertyFactory.createEntity("artist", Artist.class);
+    public static final EntityProperty<Gallery> GALLERY = PropertyFactory.createEntity("gallery", Gallery.class);
 
     protected String name;
-    protected ValueHolder artist;
-    protected ValueHolder gallery;
+    protected ValueHolder<Artist> artist;
+    protected ValueHolder<Gallery> gallery;
 
     public String getName() {
         if(objectContext != null) {
@@ -29,17 +31,13 @@ public abstract class _Painting extends PersistentObject {
 
         return name;
     }
+
     public void setName(String name) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "name", false);
+            objectContext.propertyChanged(this, "name", this.name, name);
         }
 
-        Object oldValue = this.name;
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "name", oldValue, name);
-        }
-        
         this.name = name;
     }
 
@@ -47,25 +45,19 @@ public abstract class _Painting extends PersistentObject {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "artist", true);
         } else if (this.artist == null) {
-        	this.artist = new PersistentObjectHolder(this, "artist");
+        	this.artist = new PersistentObjectHolder<>(this, "artist");
 		}
 
-        return (Artist) artist.getValue();
+        return artist.getValue();
     }
+
     public void setArtist(Artist artist) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "artist", true);
         } else if (this.artist == null) {
-        	this.artist = new PersistentObjectHolder(this, "artist");
+        	this.artist = new PersistentObjectHolder<>(this, "artist");
 		}
 
-        // 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.artist.getValueDirectly();
-        if (objectContext != null) {
-        	objectContext.propertyChanged(this, "artist", oldValue, artist);
-        }
-        
         this.artist.setValue(artist);
     }
 
@@ -73,25 +65,19 @@ public abstract class _Painting extends PersistentObject {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "gallery", true);
         } else if (this.gallery == null) {
-        	this.gallery = new PersistentObjectHolder(this, "gallery");
+        	this.gallery = new PersistentObjectHolder<>(this, "gallery");
 		}
 
-        return (Gallery) gallery.getValue();
+        return gallery.getValue();
     }
+
     public void setGallery(Gallery gallery) {
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "gallery", true);
         } else if (this.gallery == null) {
-        	this.gallery = new PersistentObjectHolder(this, "gallery");
+        	this.gallery = new PersistentObjectHolder<>(this, "gallery");
 		}
 
-        // 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.gallery.getValueDirectly();
-        if (objectContext != null) {
-        	objectContext.propertyChanged(this, "gallery", oldValue, gallery);
-        }
-        
         this.gallery.setValue(gallery);
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java
index e61b543..5ff7823 100644
--- a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java
+++ b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Artist.java
@@ -7,7 +7,10 @@ import java.time.LocalDate;
 import java.util.List;
 
 import org.apache.cayenne.BaseDataObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.DateProperty;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.Painting;
 
 /**
@@ -22,9 +25,9 @@ public abstract class _Artist extends BaseDataObject {
 
     public static final String ID_PK_COLUMN = "ID";
 
-    public static final Property<LocalDate> DATE_OF_BIRTH = Property.create("dateOfBirth", LocalDate.class);
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final DateProperty<LocalDate> DATE_OF_BIRTH = PropertyFactory.createDate("dateOfBirth", LocalDate.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
 
     protected LocalDate dateOfBirth;
     protected String name;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
index c73de7e..0dfd941 100644
--- a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
+++ b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java
@@ -6,7 +6,9 @@ import java.io.ObjectOutputStream;
 import java.util.List;
 
 import org.apache.cayenne.BaseDataObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.ListProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.Painting;
 
 /**
@@ -21,8 +23,8 @@ public abstract class _Gallery extends BaseDataObject {
 
     public static final String ID_PK_COLUMN = "ID";
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final ListProperty<Painting> PAINTINGS = PropertyFactory.createList("paintings", Painting.class);
 
     protected String name;
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/63a32d82/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
index a75e249..e15e25f 100644
--- a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
+++ b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java
@@ -5,7 +5,9 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
 import org.apache.cayenne.BaseDataObject;
-import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.exp.property.EntityProperty;
+import org.apache.cayenne.exp.property.PropertyFactory;
+import org.apache.cayenne.exp.property.StringProperty;
 import org.apache.cayenne.tutorial.persistent.Artist;
 import org.apache.cayenne.tutorial.persistent.Gallery;
 
@@ -21,9 +23,9 @@ public abstract class _Painting extends BaseDataObject {
 
     public static final String ID_PK_COLUMN = "ID";
 
-    public static final Property<String> NAME = Property.create("name", String.class);
-    public static final Property<Artist> ARTIST = Property.create("artist", Artist.class);
-    public static final Property<Gallery> GALLERY = Property.create("gallery", Gallery.class);
+    public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class);
+    public static final EntityProperty<org.apache.cayenne.tutorial.persistent.Artist> ARTIST = PropertyFactory.createEntity("artist", org.apache.cayenne.tutorial.persistent.Artist.class);
+    public static final EntityProperty<org.apache.cayenne.tutorial.persistent.Gallery> GALLERY = PropertyFactory.createEntity("gallery", org.apache.cayenne.tutorial.persistent.Gallery.class);
 
     protected String name;
 


Mime
View raw message