cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1510116 - in /cayenne/main/trunk/framework/cayenne-core-unpublished/src/test: java/org/apache/cayenne/ java/org/apache/cayenne/testdo/oneway/ java/org/apache/cayenne/testdo/oneway/auto/ java/org/apache/cayenne/unit/di/server/ resources/
Date Sun, 04 Aug 2013 09:27:28 GMT
Author: aadamchik
Date: Sun Aug  4 09:27:28 2013
New Revision: 1510116

URL: http://svn.apache.org/r1510116
Log:
CAY-1861  Remove runtime relationships

unit tests that show what runtime rels are used for.. oddly enough we didn't have any such
tests yet

Added:
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayRels.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable1.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable2.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable3.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable4.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayRels.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable1.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable2.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable3.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable4.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-oneway-rels.xml
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/oneway-rels.map.xml
Modified:
    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/java/org/apache/cayenne/unit/di/server/ServerCase.java

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,217 @@
+/*****************************************************************
+ *   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.SQLException;
+import java.util.List;
+
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SQLSelect;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.oneway.OnewayTable1;
+import org.apache.cayenne.testdo.oneway.OnewayTable2;
+import org.apache.cayenne.testdo.oneway.OnewayTable3;
+import org.apache.cayenne.testdo.oneway.OnewayTable4;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.ONEWAY_PROJECT)
+public class OneWayRelationshipsTest extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper t1Helper;
+    private TableHelper t2Helper;
+    private TableHelper t3Helper;
+    private TableHelper t4Helper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+
+        dbHelper.deleteAll("oneway_table2");
+        dbHelper.deleteAll("oneway_table1");
+        dbHelper.deleteAll("oneway_table4");
+        dbHelper.deleteAll("oneway_table3");
+
+        t1Helper = new TableHelper(dbHelper, "oneway_table1");
+        t1Helper.setColumns("ID");
+        t2Helper = new TableHelper(dbHelper, "oneway_table2");
+        t2Helper.setColumns("ID", "TABLE1_ID");
+
+        t3Helper = new TableHelper(dbHelper, "oneway_table3");
+        t3Helper.setColumns("ID");
+        t4Helper = new TableHelper(dbHelper, "oneway_table4");
+        t4Helper.setColumns("ID", "TABLE3_ID");
+    }
+
+    public void testToOne_TwoNew() throws SQLException {
+
+        OnewayTable1 t1 = context.newObject(OnewayTable1.class);
+        OnewayTable2 t2 = context.newObject(OnewayTable2.class);
+        t2.setToOneOneWayDb(t1);
+
+        context.commitChanges();
+
+        int t1Pk = t1Helper.getInt("ID");
+        assertEquals(Cayenne.intPKForObject(t1), t1Pk);
+        int t2FK = t2Helper.getInt("TABLE1_ID");
+        assertEquals(t1Pk, t2FK);
+    }
+
+    public void testToOne_Replace() throws SQLException {
+
+        t1Helper.insert(1).insert(2);
+        t2Helper.insert(1, 1);
+
+        OnewayTable1 t11 = Cayenne.objectForPK(context, OnewayTable1.class, 1);
+        OnewayTable1 t12 = Cayenne.objectForPK(context, OnewayTable1.class, 2);
+        OnewayTable2 t2 = Cayenne.objectForPK(context, OnewayTable2.class, 1);
+
+        assertSame(t11, t2.getToOneOneWayDb());
+
+        t2.setToOneOneWayDb(t12);
+        context.commitChanges();
+
+        assertSame(t12, t2.getToOneOneWayDb());
+
+        int t2FK = t2Helper.getInt("TABLE1_ID");
+        assertEquals(2, t2FK);
+    }
+
+    public void testToOne_ReplaceWithNull() throws SQLException {
+
+        t1Helper.insert(1);
+        t2Helper.insert(1, 1);
+
+        OnewayTable1 t11 = Cayenne.objectForPK(context, OnewayTable1.class, 1);
+        OnewayTable2 t2 = Cayenne.objectForPK(context, OnewayTable2.class, 1);
+
+        assertSame(t11, t2.getToOneOneWayDb());
+
+        t2.setToOneOneWayDb(null);
+        context.commitChanges();
+
+        assertNull(t2.getToOneOneWayDb());
+
+        Object t2FK = t2Helper.getObject("TABLE1_ID");
+        assertNull(t2FK);
+    }
+
+    public void testToMany_TwoNew() throws SQLException {
+
+        OnewayTable3 t3 = context.newObject(OnewayTable3.class);
+        OnewayTable4 t4 = context.newObject(OnewayTable4.class);
+        t3.addToToManyOneWayDb(t4);
+
+        context.commitChanges();
+
+        int t3Pk = t3Helper.getInt("ID");
+        assertEquals(Cayenne.intPKForObject(t3), t3Pk);
+        int t4FK = t4Helper.getInt("TABLE3_ID");
+        assertEquals(t3Pk, t4FK);
+    }
+
+    public void testToMany_AddNew() throws SQLException {
+
+        t3Helper.insert(1);
+        t4Helper.insert(1, 1);
+
+        OnewayTable3 t3 = Cayenne.objectForPK(context, OnewayTable3.class, 1);
+        assertEquals(1, t3.getToManyOneWayDb().size());
+
+        OnewayTable4 t41 = Cayenne.objectForPK(context, OnewayTable4.class, 1);
+        assertTrue(t3.getToManyOneWayDb().contains(t41));
+
+        OnewayTable4 t42 = context.newObject(OnewayTable4.class);
+        t3.addToToManyOneWayDb(t42);
+        context.commitChanges();
+
+        assertEquals(2, t3.getToManyOneWayDb().size());
+
+        SQLSelect<Integer> fksQuery = SQLSelect.scalarQuery(Integer.class, "oneway-rels",
+                "SELECT TABLE3_ID FROM oneway_table4");
+
+        List<Integer> fks = context.select(fksQuery);
+        assertEquals(2, fks.size());
+        for (Integer fk : fks) {
+            assertEquals(Integer.valueOf(1), fk);
+        }
+    }
+
+    public void testToMany_AddExisting() throws SQLException {
+
+        t3Helper.insert(1);
+        t4Helper.insert(1, 1).insert(2, null);
+
+        OnewayTable3 t3 = Cayenne.objectForPK(context, OnewayTable3.class, 1);
+        assertEquals(1, t3.getToManyOneWayDb().size());
+
+        OnewayTable4 t41 = Cayenne.objectForPK(context, OnewayTable4.class, 1);
+        assertTrue(t3.getToManyOneWayDb().contains(t41));
+
+        OnewayTable4 t42 = Cayenne.objectForPK(context, OnewayTable4.class, 2);
+
+        t3.addToToManyOneWayDb(t42);
+        context.commitChanges();
+
+        assertEquals(2, t3.getToManyOneWayDb().size());
+
+        SQLSelect<Integer> fksQuery = SQLSelect.scalarQuery(Integer.class, "oneway-rels",
+                "SELECT TABLE3_ID FROM oneway_table4");
+
+        List<Integer> fks = context.select(fksQuery);
+        assertEquals(2, fks.size());
+        for (Integer fk : fks) {
+            assertEquals(Integer.valueOf(1), fk);
+        }
+    }
+
+    public void testToMany_RemoveExisting() throws SQLException {
+
+        t3Helper.insert(1);
+        t4Helper.insert(1, 1).insert(2, 1);
+
+        OnewayTable3 t3 = Cayenne.objectForPK(context, OnewayTable3.class, 1);
+        assertEquals(2, t3.getToManyOneWayDb().size());
+
+        OnewayTable4 t41 = Cayenne.objectForPK(context, OnewayTable4.class, 1);
+        assertTrue(t3.getToManyOneWayDb().contains(t41));
+
+        OnewayTable4 t42 = Cayenne.objectForPK(context, OnewayTable4.class, 2);
+        assertTrue(t3.getToManyOneWayDb().contains(t42));
+
+        t3.removeFromToManyOneWayDb(t42);
+        context.commitChanges();
+
+        assertEquals(1, t3.getToManyOneWayDb().size());
+
+        SQLSelect<Integer> fksQuery = SQLSelect.scalarQuery(Integer.class, "oneway-rels",
+                "SELECT TABLE3_ID FROM oneway_table4");
+
+        List<Integer> fks = context.select(fksQuery);
+        assertEquals(2, fks.size());
+        assertTrue(fks.contains(1));
+        assertTrue(fks.contains(null));
+    }
+}

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

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable1.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable1.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable1.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.oneway;
+
+import org.apache.cayenne.testdo.oneway.auto._OnewayTable1;
+
+public class OnewayTable1 extends _OnewayTable1 {
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable2.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable2.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable2.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable2.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.oneway;
+
+import org.apache.cayenne.testdo.oneway.auto._OnewayTable2;
+
+public class OnewayTable2 extends _OnewayTable2 {
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable3.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable3.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable3.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable3.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.oneway;
+
+import org.apache.cayenne.testdo.oneway.auto._OnewayTable3;
+
+public class OnewayTable3 extends _OnewayTable3 {
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable4.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable4.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable4.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/OnewayTable4.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.oneway;
+
+import org.apache.cayenne.testdo.oneway.auto._OnewayTable4;
+
+public class OnewayTable4 extends _OnewayTable4 {
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayRels.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayRels.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayRels.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayRels.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,12 @@
+package org.apache.cayenne.testdo.oneway.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 _OnewayRels {
+}
\ No newline at end of file

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable1.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable1.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable1.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,18 @@
+package org.apache.cayenne.testdo.oneway.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.exp.Property;
+
+/**
+ * Class _OnewayTable1 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 _OnewayTable1 extends CayenneDataObject {
+
+
+    public static final String ID_PK_COLUMN = "ID";
+
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable2.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable2.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable2.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable2.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,41 @@
+package org.apache.cayenne.testdo.oneway.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.testdo.oneway.OnewayTable1;
+
+/**
+ * Class _OnewayTable2 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 _OnewayTable2 extends CayenneDataObject {
+
+    @Deprecated
+    public static final String ID_PROPERTY = "id";
+    @Deprecated
+    public static final String TO_ONE_ONE_WAY_DB_PROPERTY = "toOneOneWayDb";
+
+    public static final String ID_PK_COLUMN = "ID";
+
+    public static final Property<Integer> ID = new Property<Integer>("id");
+    public static final Property<OnewayTable1> TO_ONE_ONE_WAY_DB = new Property<OnewayTable1>("toOneOneWayDb");
+
+    public void setId(Integer id) {
+        writeProperty("id", id);
+    }
+    public Integer getId() {
+        return (Integer)readProperty("id");
+    }
+
+    public void setToOneOneWayDb(OnewayTable1 toOneOneWayDb) {
+        setToOneTarget("toOneOneWayDb", toOneOneWayDb, true);
+    }
+
+    public OnewayTable1 getToOneOneWayDb() {
+        return (OnewayTable1)readProperty("toOneOneWayDb");
+    }
+
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable3.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable3.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable3.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable3.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,38 @@
+package org.apache.cayenne.testdo.oneway.auto;
+
+import java.util.List;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.exp.Property;
+import org.apache.cayenne.testdo.oneway.OnewayTable4;
+
+/**
+ * Class _OnewayTable3 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 _OnewayTable3 extends CayenneDataObject {
+
+    private static final long serialVersionUID = 1L; 
+
+    @Deprecated
+    public static final String TO_MANY_ONE_WAY_DB_PROPERTY = "toManyOneWayDb";
+
+    public static final String ID_PK_COLUMN = "ID";
+
+    public static final Property<List<OnewayTable4>> TO_MANY_ONE_WAY_DB = new
Property<List<OnewayTable4>>("toManyOneWayDb");
+
+    public void addToToManyOneWayDb(OnewayTable4 obj) {
+        addToManyTarget("toManyOneWayDb", obj, true);
+    }
+    public void removeFromToManyOneWayDb(OnewayTable4 obj) {
+        removeToManyTarget("toManyOneWayDb", obj, true);
+    }
+    @SuppressWarnings("unchecked")
+    public List<OnewayTable4> getToManyOneWayDb() {
+        return (List<OnewayTable4>)readProperty("toManyOneWayDb");
+    }
+
+
+}

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable4.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable4.java?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable4.java
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/testdo/oneway/auto/_OnewayTable4.java
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,18 @@
+package org.apache.cayenne.testdo.oneway.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.exp.Property;
+
+/**
+ * Class _OnewayTable4 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 _OnewayTable4 extends CayenneDataObject {
+
+
+    public static final String ID_PK_COLUMN = "ID";
+
+
+}

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=1510116&r1=1510115&r2=1510116&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 09:27:28 2013
@@ -54,7 +54,8 @@ import org.apache.commons.logging.LogFac
 import org.xml.sax.InputSource;
 
 /**
- * Default implementation of the AccessStack that has a single DataNode per DataMap.
+ * Default implementation of the AccessStack that has a single DataNode per
+ * DataMap.
  */
 public class SchemaBuilder {
 
@@ -65,19 +66,14 @@ 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", "map-db2.map.xml", "embeddable.map.xml",
-            "qualified.map.xml", "quoted-identifiers.map.xml",
-            "inheritance-single-table1.map.xml", "inheritance-vertical.map.xml"
-    };
+    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",
+            "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"
};
 
     // hardcoded dependent entities that should be excluded
     // if LOBs are not supported
-    private static final String[] EXTRA_EXCLUDED_FOR_NO_LOB = new String[] {
-        "CLOB_DETAIL"
-    };
+    private static final String[] EXTRA_EXCLUDED_FOR_NO_LOB = new String[] { "CLOB_DETAIL"
};
 
     private ServerCaseDataSourceFactory dataSourceFactory;
     private UnitDbAdapter unitDbAdapter;
@@ -85,9 +81,8 @@ public class SchemaBuilder {
     private DataDomain domain;
     private JdbcEventLogger jdbcEventLogger;
 
-    public SchemaBuilder(@Inject ServerCaseDataSourceFactory dataSourceFactory,
-            @Inject UnitDbAdapter unitDbAdapter, @Inject DbAdapter dbAdapter,
-            @Inject JdbcEventLogger jdbcEventLogger) {
+    public SchemaBuilder(@Inject ServerCaseDataSourceFactory dataSourceFactory, @Inject UnitDbAdapter
unitDbAdapter,
+            @Inject DbAdapter dbAdapter, @Inject JdbcEventLogger jdbcEventLogger) {
         this.dataSourceFactory = dataSourceFactory;
         this.unitDbAdapter = unitDbAdapter;
         this.dbAdapter = dbAdapter;
@@ -106,14 +101,14 @@ public class SchemaBuilder {
         }
 
         // generate schema combining all DataMaps that require schema support.
-        // Schema generation is done like that instead of per DataMap on demand to avoid
+        // Schema generation is done like that instead of per DataMap on demand
+        // to avoid
         // conflicts when dropping and generating PK objects.
 
         DataMap[] maps = new DataMap[DATA_MAPS_REQUIREING_SCHEMA_SETUP.length];
 
         for (int i = 0; i < maps.length; i++) {
-            InputStream stream = getClass().getClassLoader().getResourceAsStream(
-                    DATA_MAPS_REQUIREING_SCHEMA_SETUP[i]);
+            InputStream stream = getClass().getClassLoader().getResourceAsStream(DATA_MAPS_REQUIREING_SCHEMA_SETUP[i]);
             InputSource in = new InputSource(stream);
             in.setSystemId(DATA_MAPS_REQUIREING_SCHEMA_SETUP[i]);
             maps[i] = new MapLoader().loadDataMap(in);
@@ -133,8 +128,7 @@ public class SchemaBuilder {
             dropPKSupport();
             createSchema();
             createPKSupport();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             throw new RuntimeException("Error rebuilding schema", e);
         }
     }
@@ -183,9 +177,9 @@ public class SchemaBuilder {
     }
 
     /**
-     * Creates primary key support for all node DbEntities. Will use its facilities
-     * provided by DbAdapter to generate any necessary database objects and data for
-     * primary key support.
+     * Creates primary key support for all node DbEntities. Will use its
+     * facilities provided by DbAdapter to generate any necessary database
+     * objects and data for primary key support.
      */
     private void createPKSupport() throws Exception {
         for (DataNode node : domain.getDataNodes()) {
@@ -194,8 +188,8 @@ public class SchemaBuilder {
     }
 
     /**
-     * Helper method that orders DbEntities to satisfy referential constraints and returns
-     * an ordered list.
+     * Helper method that orders DbEntities to satisfy referential constraints
+     * and returns an ordered list.
      */
     private List<DbEntity> dbEntitiesInInsertOrder(DataNode node, DataMap map) {
         List<DbEntity> entities = new ArrayList<DbEntity>(map.getDbEntities());
@@ -235,8 +229,7 @@ public class SchemaBuilder {
                     boolean skip = false;
                     for (final DbAttribute attr : ent.getAttributes()) {
                         // check for BIN PK or FK to BIN Pk
-                        if (attr.getType() == Types.BINARY
-                                || attr.getType() == Types.VARBINARY
+                        if (attr.getType() == Types.BINARY || attr.getType() == Types.VARBINARY
                                 || attr.getType() == Types.LONGVARBINARY) {
 
                             if (attr.isPrimaryKey() || attr.isForeignKey()) {
@@ -272,7 +265,8 @@ public class SchemaBuilder {
 
             while (tables.next()) {
                 // 'toUpperCase' is needed since most databases
-                // are case insensitive, and some will convert names to lower case
+                // are case insensitive, and some will convert names to lower
+                // case
                 // (PostgreSQL)
                 String name = tables.getString("TABLE_NAME");
                 if (name != null)
@@ -296,18 +290,14 @@ public class SchemaBuilder {
                     try {
                         logger.info(dropSql);
                         stmt.execute(dropSql);
-                    }
-                    catch (SQLException sqe) {
-                        logger.warn(
-                                "Can't drop table " + ent.getName() + ", ignoring...",
-                                sqe);
+                    } catch (SQLException sqe) {
+                        logger.warn("Can't drop table " + ent.getName() + ", ignoring...",
sqe);
                     }
                 }
             }
 
             unitDbAdapter.droppedTables(conn, map);
-        }
-        finally {
+        } finally {
             conn.close();
         }
 
@@ -335,8 +325,7 @@ public class SchemaBuilder {
                 stmt.execute(query);
             }
             unitDbAdapter.createdTables(conn, map);
-        }
-        finally {
+        } finally {
             conn.close();
         }
     }
@@ -344,8 +333,7 @@ public class SchemaBuilder {
     /**
      * Returns iterator of preprocessed table create queries.
      */
-    private Collection<String> tableCreateQueries(DataNode node, DataMap map)
-            throws Exception {
+    private Collection<String> tableCreateQueries(DataNode node, DataMap map) throws
Exception {
         DbAdapter adapter = node.getAdapter();
         DbGenerator gen = new DbGenerator(adapter, map, null, domain, jdbcEventLogger);
 

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java?rev=1510116&r1=1510115&r2=1510116&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
Sun Aug  4 09:27:28 2013
@@ -37,6 +37,7 @@ public class ServerCase extends DICase {
     public static final String TESTMAP_PROJECT = "cayenne-testmap.xml";
     public static final String DEFAULT_PROJECT = "cayenne-default.xml";
     public static final String MULTINODE_PROJECT = "cayenne-multinode.xml";
+    public static final String ONEWAY_PROJECT = "cayenne-oneway-rels.xml";
 
     private static final Injector injector;
 

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-oneway-rels.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-oneway-rels.xml?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-oneway-rels.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/cayenne-oneway-rels.xml
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="7">
+	<map name="oneway-rels"/>
+</domain>

Added: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/oneway-rels.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/oneway-rels.map.xml?rev=1510116&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/oneway-rels.map.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/resources/oneway-rels.map.xml
Sun Aug  4 09:27:28 2013
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+	 project-version="7">
+	<property name="defaultPackage" value="org.apache.cayenne.testdo.oneway"/>
+	<db-entity name="oneway_table1">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="oneway_table2">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="TABLE1_ID" type="INTEGER"/>
+	</db-entity>
+	<db-entity name="oneway_table3">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="oneway_table4">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="TABLE3_ID" type="INTEGER"/>
+	</db-entity>
+	<obj-entity name="OnewayTable1" className="org.apache.cayenne.testdo.oneway.OnewayTable1"
dbEntityName="oneway_table1">
+	</obj-entity>
+	<obj-entity name="OnewayTable2" className="org.apache.cayenne.testdo.oneway.OnewayTable2"
dbEntityName="oneway_table2">
+		<obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
+	</obj-entity>
+	<obj-entity name="OnewayTable3" className="org.apache.cayenne.testdo.oneway.OnewayTable3"
dbEntityName="oneway_table3">
+	</obj-entity>
+	<obj-entity name="OnewayTable4" className="org.apache.cayenne.testdo.oneway.OnewayTable4"
dbEntityName="oneway_table4">
+	</obj-entity>
+	<db-relationship name="toOneOneWayDb" source="oneway_table2" target="oneway_table1" toMany="false">
+		<db-attribute-pair source="TABLE1_ID" target="ID"/>
+	</db-relationship>
+	<db-relationship name="toManyOneWayDb" source="oneway_table3" target="oneway_table4"
toMany="true">
+		<db-attribute-pair source="ID" target="TABLE3_ID"/>
+	</db-relationship>
+	<obj-relationship name="toOneOneWayDb" source="OnewayTable2" target="OnewayTable1" deleteRule="Nullify"
db-relationship-path="toOneOneWayDb"/>
+	<obj-relationship name="toManyOneWayDb" source="OnewayTable3" target="OnewayTable4" deleteRule="Nullify"
db-relationship-path="toManyOneWayDb"/>
+</data-map>



Mime
View raw message