This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit 7fff3112a12b4a74dd8548be3e63215a0bcc707f
Author: Matt Watson <[email protected]>
AuthorDate: Tue Feb 14 16:53:50 2023 -0800

    CAY-2794 Fix Incorrect JavaType for Vertical-Inheritance Attributes
---
 .../cayenne/access/VerticalInheritanceIT.java       |  2 ++
 .../testdo/inheritance_vertical/auto/_IvImpl.java   | 21 +++++++++++++++++++++
 .../src/test/resources/inheritance-vertical.map.xml |  2 ++
 3 files changed, 25 insertions(+)

diff --git 
a/cayenne/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java 
b/cayenne/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
index 4cfb69a00..3e9309a02 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
@@ -37,6 +37,7 @@ import org.junit.Test;
 import java.sql.SQLException;
 import java.sql.Types;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -639,6 +640,7 @@ public class VerticalInheritanceIT extends RuntimeCase {
 
                IvImpl impl = context.newObject(IvImpl.class);
                impl.setName("Impl 1");
+               impl.setAttr0(new Date());
                impl.setAttr1("attr1");
                impl.setAttr2("attr2");
                impl.setOther1(other1);
diff --git 
a/cayenne/src/test/java/org/apache/cayenne/testdo/inheritance_vertical/auto/_IvImpl.java
 
b/cayenne/src/test/java/org/apache/cayenne/testdo/inheritance_vertical/auto/_IvImpl.java
index da1ea5578..5633bea49 100644
--- 
a/cayenne/src/test/java/org/apache/cayenne/testdo/inheritance_vertical/auto/_IvImpl.java
+++ 
b/cayenne/src/test/java/org/apache/cayenne/testdo/inheritance_vertical/auto/_IvImpl.java
@@ -3,7 +3,9 @@ package org.apache.cayenne.testdo.inheritance_vertical.auto;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.util.Date;
 
+import org.apache.cayenne.exp.property.DateProperty;
 import org.apache.cayenne.exp.property.EntityProperty;
 import org.apache.cayenne.exp.property.PropertyFactory;
 import org.apache.cayenne.exp.property.StringProperty;
@@ -25,17 +27,29 @@ public abstract class _IvImpl extends IvBase {
 
     public static final String ID_PK_COLUMN = "ID";
 
+    public static final DateProperty<Date> ATTR0 = 
PropertyFactory.createDate("attr0", Date.class);
     public static final StringProperty<String> ATTR1 = 
PropertyFactory.createString("attr1", String.class);
     public static final StringProperty<String> ATTR2 = 
PropertyFactory.createString("attr2", String.class);
     public static final EntityProperty<IvOther> OTHER1 = 
PropertyFactory.createEntity("other1", IvOther.class);
     public static final EntityProperty<IvOther> OTHER2 = 
PropertyFactory.createEntity("other2", IvOther.class);
 
+    protected Date attr0;
     protected String attr1;
     protected String attr2;
 
     protected Object other1;
     protected Object other2;
 
+    public void setAttr0(Date attr0) {
+        beforePropertyWrite("attr0", this.attr0, attr0);
+        this.attr0 = attr0;
+    }
+
+    public Date getAttr0() {
+        beforePropertyRead("attr0");
+        return this.attr0;
+    }
+
     public void setAttr1(String attr1) {
         beforePropertyWrite("attr1", this.attr1, attr1);
         this.attr1 = attr1;
@@ -79,6 +93,8 @@ public abstract class _IvImpl extends IvBase {
         }
 
         switch(propName) {
+            case "attr0":
+                return this.attr0;
             case "attr1":
                 return this.attr1;
             case "attr2":
@@ -99,6 +115,9 @@ public abstract class _IvImpl extends IvBase {
         }
 
         switch (propName) {
+            case "attr0":
+                this.attr0 = (Date)val;
+                break;
             case "attr1":
                 this.attr1 = (String)val;
                 break;
@@ -127,6 +146,7 @@ public abstract class _IvImpl extends IvBase {
     @Override
     protected void writeState(ObjectOutputStream out) throws IOException {
         super.writeState(out);
+        out.writeObject(this.attr0);
         out.writeObject(this.attr1);
         out.writeObject(this.attr2);
         out.writeObject(this.other1);
@@ -136,6 +156,7 @@ public abstract class _IvImpl extends IvBase {
     @Override
     protected void readState(ObjectInputStream in) throws IOException, 
ClassNotFoundException {
         super.readState(in);
+        this.attr0 = (Date)in.readObject();
         this.attr1 = (String)in.readObject();
         this.attr2 = (String)in.readObject();
         this.other1 = in.readObject();
diff --git a/cayenne/src/test/resources/inheritance-vertical.map.xml 
b/cayenne/src/test/resources/inheritance-vertical.map.xml
index 4cf9f46e9..43c407b4f 100644
--- a/cayenne/src/test/resources/inheritance-vertical.map.xml
+++ b/cayenne/src/test/resources/inheritance-vertical.map.xml
@@ -53,6 +53,7 @@
                <db-attribute name="SUB1_NAME" type="VARCHAR" length="100"/>
        </db-entity>
        <db-entity name="IV_IMPL">
+               <db-attribute name="ATTR0" type="DATE"/>
                <db-attribute name="ATTR1" type="VARCHAR" length="100"/>
                <db-attribute name="ATTR2" type="VARCHAR" length="100"/>
                <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" 
isMandatory="true"/>
@@ -133,6 +134,7 @@
        </obj-entity>
        <obj-entity name="IvImpl" superEntityName="IvBase" 
className="org.apache.cayenne.testdo.inheritance_vertical.IvImpl">
                <qualifier><![CDATA[type = "I"]]></qualifier>
+               <obj-attribute name="attr0" type="java.util.Date" 
db-attribute-path="impl.ATTR0"/>
                <obj-attribute name="attr1" type="java.lang.String" 
db-attribute-path="impl.ATTR1"/>
                <obj-attribute name="attr2" type="java.lang.String" 
db-attribute-path="impl.ATTR2"/>
        </obj-entity>

Reply via email to