You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2018/02/08 13:30:54 UTC
cayenne git commit: CAY-2405 Broken prefetch of entity with
inheritance and attribute with custom java type
Repository: cayenne
Updated Branches:
refs/heads/STABLE-4.0 f6772c064 -> 2e4a10f0e
CAY-2405 Broken prefetch of entity with inheritance and attribute with custom java type
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/2e4a10f0
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/2e4a10f0
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/2e4a10f0
Branch: refs/heads/STABLE-4.0
Commit: 2e4a10f0e2925f67aebe7c47163fbf05a3e36ed7
Parents: f6772c0
Author: Nikita Timofeev <st...@gmail.com>
Authored: Thu Feb 8 16:28:07 2018 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Thu Feb 8 16:28:07 2018 +0300
----------------------------------------------------------------------
RELEASE-NOTES.txt | 1 +
.../select/DefaultSelectTranslator.java | 61 ++++----
.../query/QueryWithInheritancePrefetchIT.java | 141 +++++++++++++++++++
.../testdo/inheritance_with_enum/Dependent.java | 28 ++++
.../testdo/inheritance_with_enum/Root.java | 28 ++++
.../testdo/inheritance_with_enum/Sub.java | 28 ++++
.../testdo/inheritance_with_enum/Type.java | 28 ++++
.../inheritance_with_enum/auto/_Dependent.java | 38 +++++
.../inheritance_with_enum/auto/_Root.java | 52 +++++++
.../testdo/inheritance_with_enum/auto/_Sub.java | 28 ++++
.../cayenne/unit/di/server/CayenneProjects.java | 1 +
.../cayenne/unit/di/server/SchemaBuilder.java | 2 +-
.../resources/cayenne-inheritance-with-enum.xml | 4 +
.../resources/inheritance-with-enum.map.xml | 38 +++++
14 files changed, 453 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 1212a99..030b5f1 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -26,6 +26,7 @@ CAY-2388 Modeler: Visualization issues with undo/redo actions for attributes and
CAY-2389 DbEntity qualifier with DbPath expression translates into wrong SQL
CAY-2392 Modeler: Unable to remove DataNode
CAY-2401 Modeler: NPE in ObjEntity sync action
+CAY-2405 Broken prefetch of entity with inheritance and attribute with custom java type
----------------------------------
Release: 4.0.B2
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
index bcb4c9b..e455901 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/DefaultSelectTranslator.java
@@ -692,8 +692,8 @@ public class DefaultSelectTranslator extends QueryAssembler implements SelectTra
resetJoinStack();
DbRelationship r = null;
- for (PathComponent<DbAttribute, DbRelationship> component : table.resolvePath(dbPrefetch,
- getPathAliases())) {
+ for (PathComponent<DbAttribute, DbRelationship> component :
+ table.resolvePath(dbPrefetch, getPathAliases())) {
r = component.getRelationship();
dbRelationshipAdded(r, JoinType.LEFT_OUTER, null);
}
@@ -703,35 +703,48 @@ public class DefaultSelectTranslator extends QueryAssembler implements SelectTra
, prefetch, oe.getName());
}
- // add columns from the target entity, including those that are
- // matched
- // against the FK of the source entity. This is needed to
- // determine
- // whether optional relationships are null
+ // add columns from the target entity, including those that are matched
+ // against the FK of the source entity.
+ // This is needed to determine whether optional relationships are null
- // go via target OE to make sure that Java types are mapped
- // correctly...
+ // go via target OE to make sure that Java types are mapped correctly...
ObjRelationship targetRel = (ObjRelationship) prefetchExp.evaluate(oe);
ObjEntity targetEntity = targetRel.getTargetEntity();
- String labelPrefix = dbPrefetch.getPath();
- for (ObjAttribute oa : targetEntity.getAttributes()) {
- Iterator<CayenneMapEntry> dbPathIterator = oa.getDbPathIterator();
- while (dbPathIterator.hasNext()) {
- Object pathPart = dbPathIterator.next();
+ final String labelPrefix = dbPrefetch.getPath();
+
+ PropertyVisitor prefetchVisitor = new PropertyVisitor() {
+ public boolean visitAttribute(AttributeProperty property) {
+ ObjAttribute oa = property.getAttribute();
+ Iterator<CayenneMapEntry> dbPathIterator = oa.getDbPathIterator();
+ while (dbPathIterator.hasNext()) {
+ Object pathPart = dbPathIterator.next();
+
+ if (pathPart == null) {
+ throw new CayenneRuntimeException("ObjAttribute has no component: %s", oa.getName());
+ } else if (pathPart instanceof DbRelationship) {
+ DbRelationship rel = (DbRelationship) pathPart;
+ dbRelationshipAdded(rel, JoinType.INNER, null);
+ } else if (pathPart instanceof DbAttribute) {
+ DbAttribute dbAttr = (DbAttribute) pathPart;
+
+ appendColumn(columns, oa, dbAttr, attributes, labelPrefix + '.' + dbAttr.getName());
+ }
+ }
+ return true;
+ }
- if (pathPart == null) {
- throw new CayenneRuntimeException("ObjAttribute has no component: %s", oa.getName());
- } else if (pathPart instanceof DbRelationship) {
- DbRelationship rel = (DbRelationship) pathPart;
- dbRelationshipAdded(rel, JoinType.INNER, null);
- } else if (pathPart instanceof DbAttribute) {
- DbAttribute attribute = (DbAttribute) pathPart;
+ public boolean visitToMany(ToManyProperty property) {
+ return true;
+ }
- appendColumn(columns, oa, attribute, attributes, labelPrefix + '.' + attribute.getName());
- }
+ public boolean visitToOne(ToOneProperty property) {
+ return true;
}
- }
+ };
+
+ ClassDescriptor prefetchClassDescriptor = entityResolver.getClassDescriptor(targetEntity.getName());
+ prefetchClassDescriptor.visitAllProperties(prefetchVisitor);
// append remaining target attributes such as keys
DbEntity targetDbEntity = r.getTargetEntity();
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/query/QueryWithInheritancePrefetchIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/QueryWithInheritancePrefetchIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/QueryWithInheritancePrefetchIT.java
new file mode 100644
index 0000000..7330932
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/QueryWithInheritancePrefetchIT.java
@@ -0,0 +1,141 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.query;
+
+import java.util.List;
+
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.inheritance_with_enum.Dependent;
+import org.apache.cayenne.testdo.inheritance_with_enum.Root;
+import org.apache.cayenne.testdo.inheritance_with_enum.Sub;
+import org.apache.cayenne.testdo.inheritance_with_enum.Type;
+import org.apache.cayenne.unit.di.DataChannelInterceptor;
+import org.apache.cayenne.unit.di.UnitTestClosure;
+import org.apache.cayenne.unit.di.server.CayenneProjects;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * This one is about https://issues.apache.org/jira/browse/CAY-2405
+ */
+@UseServerRuntime(CayenneProjects.INHERITANCE_WITH_ENUM_PROJECT)
+public class QueryWithInheritancePrefetchIT extends ServerCase {
+
+ @Inject
+ private ServerRuntime runtime;
+
+ @Inject
+ private DBHelper dbHelper;
+
+ @Inject
+ private DataChannelInterceptor queryInterceptor;
+
+ @Before
+ public void createTestData() throws Exception {
+ TableHelper tRoot = new TableHelper(dbHelper, "iwe_root");
+ tRoot.setColumns("id", "type", "name", "enum");
+
+ tRoot.insert(1, 0, "root1", null);
+ tRoot.insert(2, 1, "enum1", Type.type1.ordinal());
+ tRoot.insert(3, 1, "enum2", Type.type2.ordinal());
+
+ TableHelper tDependent = new TableHelper(dbHelper, "iwe_dependent");
+ tDependent.setColumns("id", "root_id", "name");
+
+ tDependent.insert(1, 1, "test1");
+ tDependent.insert(2, 2, "test2");
+ tDependent.insert(3, 3, "test3");
+ }
+
+ /**
+ * Validate that direct select of objects works
+ */
+ @Test
+ public void directQuery() {
+ List<Root> result = ObjectSelect.query(Root.class)
+ .orderBy("db:" + Root.ID_PK_COLUMN)
+ .select(runtime.newContext());
+
+ assertEquals(3, result.size());
+
+ assertNotNull(result.get(0));
+ assertFalse(result.get(0) instanceof Sub);
+ assertTrue(result.get(1) instanceof Sub);
+ assertTrue(result.get(2) instanceof Sub);
+
+ assertEquals(Type.type1, ((Sub)result.get(1)).getEnum());
+ assertEquals(Type.type2, ((Sub)result.get(2)).getEnum());
+ }
+
+ @Test
+ public void queryWithJointPrefetch() {
+ List<Dependent> result = ObjectSelect.query(Dependent.class)
+ .prefetch(Dependent.ROOT.joint())
+ .select(runtime.newContext());
+
+ assertPrefetchResult(result);
+ }
+
+ @Test
+ public void queryWithDisjointPrefetch() {
+ List<Dependent> result = ObjectSelect.query(Dependent.class)
+ .prefetch(Dependent.ROOT.disjoint())
+ .select(runtime.newContext());
+
+ assertPrefetchResult(result);
+ }
+
+ @Test
+ public void queryWithDisjointByIdPrefetch() {
+ List<Dependent> result = ObjectSelect.query(Dependent.class)
+ .prefetch(Dependent.ROOT.disjointById())
+ .select(runtime.newContext());
+
+ assertPrefetchResult(result);
+ }
+
+ private void assertPrefetchResult(final List<Dependent> result) {
+ assertEquals(3, result.size());
+
+ queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+ @Override
+ public void execute() {
+ assertNotNull(result.get(0).getRoot());
+ assertFalse(result.get(0).getRoot() instanceof Sub);
+ assertTrue(result.get(1).getRoot() instanceof Sub);
+ assertTrue(result.get(2).getRoot() instanceof Sub);
+
+ assertEquals(Type.type1, ((Sub) result.get(1).getRoot()).getEnum());
+ assertEquals(Type.type2, ((Sub) result.get(2).getRoot()).getEnum());
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Dependent.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Dependent.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Dependent.java
new file mode 100644
index 0000000..05001b5
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Dependent.java
@@ -0,0 +1,28 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.testdo.inheritance_with_enum;
+
+import org.apache.cayenne.testdo.inheritance_with_enum.auto._Dependent;
+
+public class Dependent extends _Dependent {
+
+ private static final long serialVersionUID = 1L;
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Root.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Root.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Root.java
new file mode 100644
index 0000000..8f60d9d
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Root.java
@@ -0,0 +1,28 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.testdo.inheritance_with_enum;
+
+import org.apache.cayenne.testdo.inheritance_with_enum.auto._Root;
+
+public class Root extends _Root {
+
+ private static final long serialVersionUID = 1L;
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Sub.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Sub.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Sub.java
new file mode 100644
index 0000000..173406b
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Sub.java
@@ -0,0 +1,28 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.testdo.inheritance_with_enum;
+
+import org.apache.cayenne.testdo.inheritance_with_enum.auto._Sub;
+
+public class Sub extends _Sub {
+
+ private static final long serialVersionUID = 1L;
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Type.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Type.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Type.java
new file mode 100644
index 0000000..0a283c7
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/Type.java
@@ -0,0 +1,28 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.testdo.inheritance_with_enum;
+
+/**
+ * @since 4.1
+ */
+public enum Type {
+ type1,
+ type2
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Dependent.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Dependent.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Dependent.java
new file mode 100644
index 0000000..5a7e3b8
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Dependent.java
@@ -0,0 +1,38 @@
+package org.apache.cayenne.testdo.inheritance_with_enum.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.testdo.inheritance_with_enum.Root;
+
+/**
+ * Class _Dependent was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _Dependent extends CayenneDataObject {
+
+ 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<Root> ROOT = Property.create("root", Root.class);
+
+ public void setName(String name) {
+ writeProperty("name", name);
+ }
+ public String getName() {
+ return (String)readProperty("name");
+ }
+
+ public void setRoot(Root root) {
+ setToOneTarget("root", root, true);
+ }
+
+ public Root getRoot() {
+ return (Root)readProperty("root");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Root.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Root.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Root.java
new file mode 100644
index 0000000..6ee1bbe
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Root.java
@@ -0,0 +1,52 @@
+package org.apache.cayenne.testdo.inheritance_with_enum.auto;
+
+import java.util.List;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.testdo.inheritance_with_enum.Dependent;
+
+/**
+ * Class _Root was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _Root extends CayenneDataObject {
+
+ 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<Short> TYPE = Property.create("type", Short.class);
+ public static final Property<List<Dependent>> DEPENDENTS = Property.create("dependents", List.class);
+
+ public void setName(String name) {
+ writeProperty("name", name);
+ }
+ public String getName() {
+ return (String)readProperty("name");
+ }
+
+ public void setType(short type) {
+ writeProperty("type", type);
+ }
+ public short getType() {
+ Object value = readProperty("type");
+ return (value != null) ? (Short) value : 0;
+ }
+
+ public void addToDependents(Dependent obj) {
+ addToManyTarget("dependents", obj, true);
+ }
+ public void removeFromDependents(Dependent obj) {
+ removeToManyTarget("dependents", obj, true);
+ }
+ @SuppressWarnings("unchecked")
+ public List<Dependent> getDependents() {
+ return (List<Dependent>)readProperty("dependents");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Sub.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Sub.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Sub.java
new file mode 100644
index 0000000..148f25d
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/inheritance_with_enum/auto/_Sub.java
@@ -0,0 +1,28 @@
+package org.apache.cayenne.testdo.inheritance_with_enum.auto;
+
+import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.testdo.inheritance_with_enum.Root;
+import org.apache.cayenne.testdo.inheritance_with_enum.Type;
+
+/**
+ * Class _Sub was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _Sub extends Root {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String ID_PK_COLUMN = "id";
+
+ public static final Property<Type> ENUM = Property.create("enum", Type.class);
+
+ public void setEnum(Type _enum) {
+ writeProperty("enum", _enum);
+ }
+ public Type getEnum() {
+ return (Type)readProperty("enum");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
index 0cd6372..d55e5bf 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
@@ -80,4 +80,5 @@ public class CayenneProjects {
public static final String UUID_PROJECT = "cayenne-uuid.xml";
public static final String CUSTOM_NAME_PROJECT = "custom-name-file.xml";
public static final String WEIGHTED_SORT_PROJECT = "cayenne-weighted-sort.xml";
+ public static final String INHERITANCE_WITH_ENUM_PROJECT = "cayenne-inheritance-with-enum.xml";
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
index 69c4400..ed351b4 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
@@ -80,7 +80,7 @@ public class SchemaBuilder {
"table-primitives.map.xml", "generic.map.xml", "map-db1.map.xml", "map-db2.map.xml", "embeddable.map.xml",
"qualified.map.xml", "quoted-identifiers.map.xml", "inheritance-single-table1.map.xml",
"inheritance-vertical.map.xml", "oneway-rels.map.xml", "unsupported-distinct-types.map.xml",
- "array-type.map.xml", "cay-2032.map.xml", "weighted-sort.map.xml" };
+ "array-type.map.xml", "cay-2032.map.xml", "weighted-sort.map.xml", "inheritance-with-enum.map.xml" };
// hardcoded dependent entities that should be excluded
// if LOBs are not supported
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/resources/cayenne-inheritance-with-enum.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/cayenne-inheritance-with-enum.xml b/cayenne-server/src/test/resources/cayenne-inheritance-with-enum.xml
new file mode 100644
index 0000000..4f2ad44
--- /dev/null
+++ b/cayenne-server/src/test/resources/cayenne-inheritance-with-enum.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="9">
+ <map name="inheritance-with-enum"/>
+</domain>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2e4a10f0/cayenne-server/src/test/resources/inheritance-with-enum.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/inheritance-with-enum.map.xml b/cayenne-server/src/test/resources/inheritance-with-enum.map.xml
new file mode 100644
index 0000000..30e2138
--- /dev/null
+++ b/cayenne-server/src/test/resources/inheritance-with-enum.map.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/9/modelMap"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://cayenne.apache.org/schema/9/modelMap http://cayenne.apache.org/schema/9/modelMap.xsd"
+ project-version="9">
+ <property name="defaultPackage" value="org.apache.cayenne.testdo.inheritance_with_enum"/>
+ <db-entity name="iwe_dependent">
+ <db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="name" type="VARCHAR" length="200"/>
+ <db-attribute name="root_id" type="INTEGER"/>
+ </db-entity>
+ <db-entity name="iwe_root">
+ <db-attribute name="enum" type="INTEGER"/>
+ <db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="name" type="VARCHAR" length="255"/>
+ <db-attribute name="type" type="SMALLINT" isMandatory="true"/>
+ </db-entity>
+ <obj-entity name="Dependent" className="org.apache.cayenne.testdo.inheritance_with_enum.Dependent" dbEntityName="iwe_dependent">
+ <obj-attribute name="name" type="java.lang.String" db-attribute-path="name"/>
+ </obj-entity>
+ <obj-entity name="Root" className="org.apache.cayenne.testdo.inheritance_with_enum.Root" dbEntityName="iwe_root">
+ <qualifier><![CDATA[type = 0]]></qualifier>
+ <obj-attribute name="name" type="java.lang.String" db-attribute-path="name"/>
+ <obj-attribute name="type" type="short" db-attribute-path="type"/>
+ </obj-entity>
+ <obj-entity name="Sub" superEntityName="Root" className="org.apache.cayenne.testdo.inheritance_with_enum.Sub">
+ <qualifier><![CDATA[type = 1]]></qualifier>
+ <obj-attribute name="enum" type="org.apache.cayenne.testdo.inheritance_with_enum.Type" db-attribute-path="enum"/>
+ </obj-entity>
+ <db-relationship name="root" source="iwe_dependent" target="iwe_root" toMany="false">
+ <db-attribute-pair source="root_id" target="id"/>
+ </db-relationship>
+ <db-relationship name="dependents" source="iwe_root" target="iwe_dependent" toMany="true">
+ <db-attribute-pair source="id" target="root_id"/>
+ </db-relationship>
+ <obj-relationship name="root" source="Dependent" target="Root" deleteRule="Nullify" db-relationship-path="root"/>
+ <obj-relationship name="dependents" source="Root" target="Dependent" deleteRule="Deny" db-relationship-path="dependents"/>
+</data-map>