You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2013/08/04 20:59:03 UTC

svn commit: r1510312 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/ framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/ framework/cayenne-core-unpub...

Author: aadamchik
Date: Sun Aug  4 18:59:03 2013
New Revision: 1510312

URL: http://svn.apache.org/r1510312
Log:
CAY-1834  Exception: ToManyList cannot be cast to DataObject

Added:
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/ManyToManyNoJoinTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Activity.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/ActivityResult.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Relationships1.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Activity.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_ActivityResult.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Relationships1.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/relationships1.map.xml
Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-relationships.xml

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1510312&r1=1510311&r2=1510312&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Sun Aug  4 18:59:03 2013
@@ -30,6 +30,7 @@ Bug Fixes:
 CAY-1695 Unexpected null value in bidirectional one-to-one prefetch 
 CAY-1736 IllegalArgumentException when synchronizing entities in the Modeler
 CAY-1818 Fix copyright year in the Modeler "about" panel
+CAY-1834 Exception: ToManyList cannot be cast to DataObject 
 CAY-1857 Problem with hotkeys 
 CAY-1859 NullPointerException when importing EOModel 
 

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/ManyToManyNoJoinTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/ManyToManyNoJoinTest.java?rev=1510312&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/ManyToManyNoJoinTest.java (added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/ManyToManyNoJoinTest.java Sun Aug  4 18:59:03 2013
@@ -0,0 +1,59 @@
+/*****************************************************************
+ *   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;
+
+import java.sql.Date;
+
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.r1.Activity;
+import org.apache.cayenne.testdo.r1.ActivityResult;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
+public class ManyToManyNoJoinTest extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("ACTIVITY");
+        dbHelper.deleteAll("RESULT");
+    }
+
+    public void testValidateForSave1() throws Exception {
+        ActivityResult result = context.newObject(ActivityResult.class);
+        result.setAppointDate(new Date(System.currentTimeMillis()));
+        result.setAppointNo(1);
+        result.setField("xx");
+
+        Activity activity = context.newObject(Activity.class);
+        activity.setAppointmentDate(result.getAppointDate());
+        activity.setAppointmentNo(result.getAppointNo());
+
+        activity.addToResults(result);
+        context.commitChanges();
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Activity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Activity.java?rev=1510312&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Activity.java (added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Activity.java Sun Aug  4 18:59:03 2013
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.r1;
+
+import org.apache.cayenne.testdo.r1.auto._Activity;
+
+public class Activity extends _Activity {
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/ActivityResult.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/ActivityResult.java?rev=1510312&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/ActivityResult.java (added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/ActivityResult.java Sun Aug  4 18:59:03 2013
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.r1;
+
+import org.apache.cayenne.testdo.r1.auto._ActivityResult;
+
+public class ActivityResult extends _ActivityResult {
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Relationships1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Relationships1.java?rev=1510312&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Relationships1.java (added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/Relationships1.java Sun Aug  4 18:59:03 2013
@@ -0,0 +1,18 @@
+package org.apache.cayenne.testdo.r1;
+
+import org.apache.cayenne.testdo.r1.auto._Relationships1;
+
+public class Relationships1 extends _Relationships1 {
+
+    private static Relationships1 instance;
+
+    private Relationships1() {}
+
+    public static Relationships1 getInstance() {
+        if(instance == null) {
+            instance = new Relationships1();
+        }
+
+        return instance;
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Activity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Activity.java?rev=1510312&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Activity.java (added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Activity.java Sun Aug  4 18:59:03 2013
@@ -0,0 +1,58 @@
+package org.apache.cayenne.testdo.r1.auto;
+
+import java.sql.Date;
+import java.util.Map;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.testdo.r1.ActivityResult;
+
+/**
+ * Class _Activity 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 _Activity extends CayenneDataObject {
+
+    @Deprecated
+    public static final String APPOINTMENT_DATE_PROPERTY = "appointmentDate";
+    @Deprecated
+    public static final String APPOINTMENT_NO_PROPERTY = "appointmentNo";
+    @Deprecated
+    public static final String RESULTS_PROPERTY = "results";
+
+    public static final String ACTIVITY_ID_PK_COLUMN = "ACTIVITY_ID";
+
+    public static final Property<Date> APPOINTMENT_DATE = new Property<Date>("appointmentDate");
+    public static final Property<Integer> APPOINTMENT_NO = new Property<Integer>("appointmentNo");
+    public static final Property<Map<String, ActivityResult>> RESULTS = new Property<Map<String, ActivityResult>>("results");
+
+    public void setAppointmentDate(Date appointmentDate) {
+        writeProperty("appointmentDate", appointmentDate);
+    }
+    public Date getAppointmentDate() {
+        return (Date)readProperty("appointmentDate");
+    }
+
+    public void setAppointmentNo(int appointmentNo) {
+        writeProperty("appointmentNo", appointmentNo);
+    }
+    public int getAppointmentNo() {
+        Object value = readProperty("appointmentNo");
+        return (value != null) ? (Integer) value : 0;
+    }
+
+    public void addToResults(ActivityResult obj) {
+        addToManyTarget("results", obj, true);
+    }
+    public void removeFromResults(ActivityResult obj) {
+        removeToManyTarget("results", obj, true);
+    }
+    @SuppressWarnings("unchecked")
+    public Map<String, ActivityResult> getResults() {
+        return (Map<String, ActivityResult>)readProperty("results");
+    }
+
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_ActivityResult.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_ActivityResult.java?rev=1510312&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_ActivityResult.java (added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_ActivityResult.java Sun Aug  4 18:59:03 2013
@@ -0,0 +1,53 @@
+package org.apache.cayenne.testdo.r1.auto;
+
+import java.sql.Date;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.exp.Property;
+
+/**
+ * Class _ActivityResult 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 _ActivityResult extends CayenneDataObject {
+
+    @Deprecated
+    public static final String APPOINT_DATE_PROPERTY = "appointDate";
+    @Deprecated
+    public static final String APPOINT_NO_PROPERTY = "appointNo";
+    @Deprecated
+    public static final String FIELD_PROPERTY = "field";
+
+    public static final String APPOINT_DATE_PK_COLUMN = "APPOINT_DATE";
+    public static final String APPOINT_NO_PK_COLUMN = "APPOINT_NO";
+    public static final String RESULTNAME_PK_COLUMN = "RESULTNAME";
+
+    public static final Property<Date> APPOINT_DATE = new Property<Date>("appointDate");
+    public static final Property<Integer> APPOINT_NO = new Property<Integer>("appointNo");
+    public static final Property<String> FIELD = new Property<String>("field");
+
+    public void setAppointDate(Date appointDate) {
+        writeProperty("appointDate", appointDate);
+    }
+    public Date getAppointDate() {
+        return (Date)readProperty("appointDate");
+    }
+
+    public void setAppointNo(int appointNo) {
+        writeProperty("appointNo", appointNo);
+    }
+    public int getAppointNo() {
+        Object value = readProperty("appointNo");
+        return (value != null) ? (Integer) value : 0;
+    }
+
+    public void setField(String field) {
+        writeProperty("field", field);
+    }
+    public String getField() {
+        return (String)readProperty("field");
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Relationships1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Relationships1.java?rev=1510312&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Relationships1.java (added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/r1/auto/_Relationships1.java Sun Aug  4 18:59:03 2013
@@ -0,0 +1,12 @@
+package org.apache.cayenne.testdo.r1.auto;
+
+
+
+/**
+ * This class 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 class _Relationships1 {
+}
\ No newline at end of file

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java?rev=1510312&r1=1510311&r2=1510312&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java Sun Aug  4 18:59:03 2013
@@ -67,7 +67,7 @@ public class SchemaBuilder {
     public static final String SKIP_SCHEMA_KEY = "cayenne.test.schema.skip";
 
     private static String[] DATA_MAPS_REQUIREING_SCHEMA_SETUP = { "testmap.map.xml", "people.map.xml",
-            "locking.map.xml", "relationships.map.xml", "multi-tier.map.xml", "generic.map.xml", "map-db1.map.xml",
+            "locking.map.xml", "relationships.map.xml", "relationships1.map.xml", "multi-tier.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" };
 

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-relationships.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-relationships.xml?rev=1510312&r1=1510311&r2=1510312&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-relationships.xml (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-relationships.xml Sun Aug  4 18:59:03 2013
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <domain project-version="6">
 	<map name="relationships"/>
+	<map name="relationships1"/>
 </domain>

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/relationships1.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/relationships1.map.xml?rev=1510312&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/relationships1.map.xml (added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/relationships1.map.xml Sun Aug  4 18:59:03 2013
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+	 project-version="6">
+	<property name="defaultPackage" value="org.apache.cayenne.testdo.r1"/>
+	<db-entity name="ACTIVITY">
+		<db-attribute name="ACTIVITY_ID" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="50"/>
+		<db-attribute name="APPOINT_DATE" type="DATE" isMandatory="true"/>
+		<db-attribute name="APPOINT_NO" type="INTEGER" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="RESULT">
+		<db-attribute name="APPOINT_DATE" type="DATE" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="APPOINT_NO" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="RESULTNAME" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="50"/>
+	</db-entity>
+	<obj-entity name="Activity" className="org.apache.cayenne.testdo.r1.Activity" dbEntityName="ACTIVITY">
+		<obj-attribute name="appointmentDate" type="java.sql.Date" db-attribute-path="APPOINT_DATE"/>
+		<obj-attribute name="appointmentNo" type="int" db-attribute-path="APPOINT_NO"/>
+	</obj-entity>
+	<obj-entity name="ActivityResult" className="org.apache.cayenne.testdo.r1.ActivityResult" dbEntityName="RESULT">
+		<obj-attribute name="appointDate" type="java.sql.Date" db-attribute-path="APPOINT_DATE"/>
+		<obj-attribute name="appointNo" type="int" db-attribute-path="APPOINT_NO"/>
+		<obj-attribute name="field" type="java.lang.String" db-attribute-path="RESULTNAME"/>
+	</obj-entity>
+	<db-relationship name="ActivityResultsRel" source="ACTIVITY" target="RESULT" toMany="true">
+		<db-attribute-pair source="APPOINT_DATE" target="APPOINT_DATE"/>
+		<db-attribute-pair source="APPOINT_NO" target="APPOINT_NO"/>
+	</db-relationship>
+	<db-relationship name="ActivitiesRel" source="RESULT" target="ACTIVITY" toMany="true">
+		<db-attribute-pair source="APPOINT_DATE" target="APPOINT_DATE"/>
+		<db-attribute-pair source="APPOINT_NO" target="APPOINT_NO"/>
+	</db-relationship>
+	<obj-relationship name="results" source="Activity" target="ActivityResult" collection-type="java.util.Map" map-key="field" deleteRule="Deny" db-relationship-path="ActivityResultsRel"/>
+</data-map>