Index: test/resources/tests.xml
===================================================================
--- test/resources/tests.xml (Revision 5972)
+++ test/resources/tests.xml (Arbeitskopie)
@@ -65,6 +65,8 @@
+
+
@@ -166,6 +168,8 @@
+
+
@@ -260,6 +264,8 @@
+
+
@@ -355,6 +361,8 @@
+
+
@@ -450,6 +458,8 @@
+
+
@@ -548,6 +558,8 @@
+
+
@@ -642,6 +654,8 @@
+
+
@@ -736,6 +750,8 @@
+
+
@@ -835,6 +851,8 @@
+
+
@@ -934,6 +952,8 @@
+
+
Index: test/resources/ctf/jdo/tc7x/mapping.xml
===================================================================
--- test/resources/ctf/jdo/tc7x/mapping.xml (Revision 5972)
+++ test/resources/ctf/jdo/tc7x/mapping.xml (Arbeitskopie)
@@ -351,5 +351,58 @@
+
+
+ Main class for testing autostore attribute
+
+
+
+
+
+
+
+
+
+
+
+
+ Associated entity for testing autostore attribute
+
+
+
+
+
+
+
+
+
+
+ Main class for testing autostore attribute
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Associated entity for testing autostore attribute
+
+
+
+
+
+
+
+
+
+
+
+
\ Kein Zeilenvorschub am Ende der Datei
Index: tests/ctf/jdo/tc7x/AutostoreAssociated1.java
===================================================================
--- tests/ctf/jdo/tc7x/AutostoreAssociated1.java (Revision 0)
+++ tests/ctf/jdo/tc7x/AutostoreAssociated1.java (Revision 0)
@@ -0,0 +1,22 @@
+package ctf.jdo.tc7x;
+
+public final class AutostoreAssociated1 {
+ private Integer _id;
+ private String _name;
+
+ public Integer getId() {
+ return _id;
+ }
+
+ public void setId(final Integer id) {
+ _id = id;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(final String name) {
+ _name = name;
+ }
+}
Index: tests/ctf/jdo/tc7x/AutostoreAssociatedMany.java
===================================================================
--- tests/ctf/jdo/tc7x/AutostoreAssociatedMany.java (Revision 0)
+++ tests/ctf/jdo/tc7x/AutostoreAssociatedMany.java (Revision 0)
@@ -0,0 +1,31 @@
+package ctf.jdo.tc7x;
+
+public final class AutostoreAssociatedMany {
+ private Integer _id;
+ private String _name;
+ private AutostoreMainMany _main;
+
+ public Integer getId() {
+ return _id;
+ }
+
+ public void setId(final Integer id) {
+ _id = id;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(final String name) {
+ _name = name;
+ }
+
+ public AutostoreMainMany getMain() {
+ return _main;
+ }
+
+ public void setMain(final AutostoreMainMany main) {
+ _main = main;
+ }
+}
Index: tests/ctf/jdo/tc7x/AutostoreMainMany.java
===================================================================
--- tests/ctf/jdo/tc7x/AutostoreMainMany.java (Revision 0)
+++ tests/ctf/jdo/tc7x/AutostoreMainMany.java (Revision 0)
@@ -0,0 +1,34 @@
+package ctf.jdo.tc7x;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public final class AutostoreMainMany {
+ private Integer _id;
+ private String _name;
+ private List _associatedMany = new ArrayList();
+
+ public Integer getId() {
+ return _id;
+ }
+
+ public void setId(final Integer id) {
+ _id = id;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(final String name) {
+ _name = name;
+ }
+
+ public List getAssociatedMany() {
+ return _associatedMany;
+ }
+
+ public void setAssociatedMany(final List associatedMany) {
+ this._associatedMany = associatedMany;
+ }
+}
Index: tests/ctf/jdo/tc7x/TestAutostore.java
===================================================================
--- tests/ctf/jdo/tc7x/TestAutostore.java (Revision 0)
+++ tests/ctf/jdo/tc7x/TestAutostore.java (Revision 0)
@@ -0,0 +1,322 @@
+/**
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright
+ * statements and notices. Redistributions must also contain a
+ * copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the
+ * above copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. The name "Exolab" must not be used to endorse or promote
+ * products derived from this Software without prior written
+ * permission of Intalio, Inc. For written permission,
+ * please contact info@exolab.org.
+ *
+ * 4. Products derived from this Software may not be called "Exolab"
+ * nor may "Exolab" appear in their names without prior written
+ * permission of Intalio, Inc. Exolab is a registered
+ * trademark of Intalio, Inc.
+ *
+ * 5. Due credit should be given to the Exolab Project
+ * (http://www.exolab.org/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Copyright 1999 (C) Intalio, Inc. All Rights Reserved.
+ *
+ * $Id: CachedOid.java 5916 2006-05-06 23:34:05 +0000 (Sat, 06 May 2006) rjoachim $
+ */
+
+
+package ctf.jdo.tc7x;
+
+import harness.CastorTestCase;
+import harness.TestHarness;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import jdo.JDOCategory;
+
+import org.exolab.castor.jdo.Database;
+import org.exolab.castor.jdo.OQLQuery;
+import org.exolab.castor.jdo.ObjectNotFoundException;
+import org.exolab.castor.jdo.PersistenceException;
+import org.exolab.castor.jdo.QueryResults;
+
+public class TestAutostore extends CastorTestCase {
+
+ private JDOCategory _category;
+
+ private Connection _conn;
+
+ /**
+ * Constructor
+ *
+ * @param category The test suite for these tests
+ */
+ public TestAutostore(final TestHarness category) {
+ super(category, "TC79a", "Test auto-store attribute");
+ _category = (JDOCategory) category;
+ }
+
+// /**
+// * Get a JDO database
+// */
+// public void setUp() throws PersistenceException, SQLException {
+// // Database db = _category.getDatabase();
+// _conn = _category.getJDBCConnection();
+// _conn.setAutoCommit(false);
+//
+// Statement stmt = _conn.createStatement();
+// stmt.executeUpdate("delete from tc7x_as_main");
+// stmt.executeUpdate("delete from tc7x_as_assoc1");
+// _conn.commit();
+//
+// }
+
+ public void runTest() throws Exception {
+ testCreateNoEntityTwo();
+ testCreateWithEntityTwoNoAutoStore();
+ testCreateWithEntityTwoWithAutoStoreDeleteWithAutoStore();
+ testCreateWithEntityTwoWithAutoStoreDeleteWithoutAutoStore();
+ testQueryEntityOne();
+ }
+
+ public void testCreateNoEntityTwo() throws Exception {
+ Database db = _category.getDatabase();
+ db.begin();
+ AutostoreMain entityOne = new AutostoreMain();
+ entityOne.setId(new Integer(100));
+ entityOne.setName("entity1.100");
+ db.create(entityOne);
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(100));
+ assertNotNull(entityOne);
+ assertEquals(100, entityOne.getId().intValue());
+ assertEquals("entity1.100", entityOne.getName());
+ assertNull(entityOne.getAssociatedOne());
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(100));
+ db.remove(entityOne);
+ db.commit();
+ db.close();
+}
+
+ public void testCreateWithEntityTwoNoAutoStore() throws Exception {
+ Database db = _category.getDatabase();
+ db.begin();
+ AutostoreAssociated1 entityTwo = new AutostoreAssociated1();
+ entityTwo.setId(new Integer(200));
+ entityTwo.setName("entity1.200");
+ AutostoreMain entityOne = new AutostoreMain();
+ entityOne.setId(new Integer(200));
+ entityOne.setName("entity2.200");
+ entityOne.setAssociatedOne(entityTwo);
+ db.create(entityOne);
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(200));
+ assertNotNull(entityOne);
+ assertEquals(200, entityOne.getId().intValue());
+ assertEquals("entity2.200", entityOne.getName());
+ assertNull(entityOne.getAssociatedOne());
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(200));
+ db.remove(entityOne);
+ db.commit();
+
+ db.close();
+ }
+
+ public void testCreateWithEntityTwoWithAutoStoreDeleteWithoutAutoStore()
+ throws Exception {
+ Database db = _category.getDatabase();
+ db.setAutoStore(true);
+
+ db.begin();
+ AutostoreAssociated1 assocOne = new AutostoreAssociated1();
+ assocOne.setId(new Integer(300));
+ assocOne.setName("entity2.300");
+ AutostoreMain main = new AutostoreMain();
+ main.setId(new Integer(300));
+ main.setName("entity1.300");
+ main.setAssociatedOne(assocOne);
+ db.create(main);
+ db.commit();
+
+ db.begin();
+ main = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ assertNotNull(main);
+ assertEquals(300, main.getId().intValue());
+ assertEquals("entity1.300", main.getName());
+ assertNotNull(main.getAssociatedOne());
+ assertEquals(300, main.getAssociatedOne().getId().intValue());
+ db.commit();
+
+ db.begin();
+ assocOne = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ assertNotNull(assocOne);
+ assertEquals(300, assocOne.getId().intValue());
+ assertEquals("entity2.300", assocOne.getName());
+ db.commit();
+
+ db.setAutoStore(false);
+
+ db.begin();
+ main = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ db.remove(main);
+ db.commit();
+
+ db.begin();
+ assocOne = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ assertNotNull(assocOne);
+ assertEquals(300, assocOne.getId().intValue());
+ assertEquals("entity2.300", assocOne.getName());
+
+ try {
+ main = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ fail("Expected ObjectNotFoundException");
+ } catch (ObjectNotFoundException e) {
+ //
+ }
+ db.commit();
+
+ db.begin();
+ assocOne = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ db.remove(assocOne);
+ db.commit();
+
+ db.begin();
+ try {
+ assocOne = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ fail("Expected ObjectNotFoundException");
+ } catch (ObjectNotFoundException e) {
+ //
+ }
+ db.commit();
+
+ db.close();
+ }
+
+ public void testCreateWithEntityTwoWithAutoStoreDeleteWithAutoStore()
+ throws Exception {
+ Database db = _category.getDatabase();
+ db.setAutoStore(true);
+
+ db.begin();
+ AutostoreAssociated1 assocOne = new AutostoreAssociated1();
+ assocOne.setId(new Integer(300));
+ assocOne.setName("entity2.300");
+ AutostoreMain main = new AutostoreMain();
+ main.setId(new Integer(300));
+ main.setName("entity1.300");
+ main.setAssociatedOne(assocOne);
+ db.create(main);
+ db.commit();
+
+ db.begin();
+ main = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ assertNotNull(main);
+ assertEquals(300, main.getId().intValue());
+ assertEquals("entity1.300", main.getName());
+ assertNotNull(main.getAssociatedOne());
+ assertEquals(300, main.getAssociatedOne().getId().intValue());
+ db.commit();
+
+ db.begin();
+ assocOne = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ assertNotNull(assocOne);
+ assertEquals(300, assocOne.getId().intValue());
+ assertEquals("entity2.300", assocOne.getName());
+ db.commit();
+
+ db.begin();
+ main = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ db.remove(main);
+ db.commit();
+
+ db.begin();
+ try {
+ main = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ fail("Expected ObjectNotFoundException");
+ } catch (ObjectNotFoundException e) {
+ //
+ }
+ try {
+ assocOne = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ // TODO: remove once support for cascading delete has been added
+// fail("Expected ObjectNotFoundException");
+ } catch (ObjectNotFoundException e) {
+ //
+ }
+ db.commit();
+
+ // TODO: remove once support for cascading deletes has been added
+ db.begin();
+ assocOne = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ db.remove(assocOne);
+ db.commit();
+
+ db.close();
+ }
+
+ /**
+ * Test method.
+ * @throws Exception For any exception thrown.
+ */
+ public void testQueryEntityOne() throws Exception {
+ Database db = _category.getDatabase();
+ db.begin();
+
+ OQLQuery query = db.getOQLQuery("SELECT entity FROM "
+ + AutostoreMain.class.getName() + " entity WHERE id = $1");
+ query.bind(new Integer(1));
+ QueryResults results = query.execute();
+
+ AutostoreMain entity = (AutostoreMain) results.next();
+
+ assertNotNull(entity);
+ assertEquals(new Integer(1), entity.getId());
+
+ AutostoreAssociated1 entity2 = entity.getAssociatedOne();
+
+ assertNotNull(entity2);
+ assertEquals(new Integer(1), entity2.getId());
+
+
+ db.commit();
+ db.close();
+ }
+}
Index: tests/ctf/jdo/tc7x/TestAutostoreMany.java
===================================================================
--- tests/ctf/jdo/tc7x/TestAutostoreMany.java (Revision 0)
+++ tests/ctf/jdo/tc7x/TestAutostoreMany.java (Revision 0)
@@ -0,0 +1,344 @@
+/**
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright
+ * statements and notices. Redistributions must also contain a
+ * copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the
+ * above copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. The name "Exolab" must not be used to endorse or promote
+ * products derived from this Software without prior written
+ * permission of Intalio, Inc. For written permission,
+ * please contact info@exolab.org.
+ *
+ * 4. Products derived from this Software may not be called "Exolab"
+ * nor may "Exolab" appear in their names without prior written
+ * permission of Intalio, Inc. Exolab is a registered
+ * trademark of Intalio, Inc.
+ *
+ * 5. Due credit should be given to the Exolab Project
+ * (http://www.exolab.org/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Copyright 1999 (C) Intalio, Inc. All Rights Reserved.
+ *
+ * $Id: CachedOid.java 5916 2006-05-06 23:34:05 +0000 (Sat, 06 May 2006) rjoachim $
+ */
+
+
+package ctf.jdo.tc7x;
+
+import harness.CastorTestCase;
+import harness.TestHarness;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import jdo.JDOCategory;
+
+import org.exolab.castor.jdo.Database;
+import org.exolab.castor.jdo.OQLQuery;
+import org.exolab.castor.jdo.ObjectNotFoundException;
+import org.exolab.castor.jdo.PersistenceException;
+import org.exolab.castor.jdo.QueryResults;
+
+public class TestAutostoreMany extends CastorTestCase {
+
+ private JDOCategory _category;
+
+ /**
+ * Constructor
+ *
+ * @param category The test suite for these tests
+ */
+ public TestAutostoreMany(final TestHarness category) {
+ super(category, "TC79aa", "Test auto-store attribute for 1:M relations");
+ _category = (JDOCategory) category;
+ }
+
+// /**
+// * Get a JDO database
+// */
+// public void setUp() throws PersistenceException, SQLException {
+// // Database db = _category.getDatabase();
+// _conn = _category.getJDBCConnection();
+// _conn.setAutoCommit(false);
+//
+// Statement stmt = _conn.createStatement();
+// stmt.executeUpdate("delete from tc7x_as_main");
+// stmt.executeUpdate("delete from tc7x_as_assoc1");
+// _conn.commit();
+//
+// }
+
+ public void runTest() throws Exception {
+ testCreateNoEntityTwo();
+ testCreateWithEntityTwoNoAutoStore();
+// testCreateWithEntityTwoWithAutoStoreDeleteWithAutoStore();
+ testCreateWithEntityTwoWithAutoStoreDeleteWithoutAutoStore();
+// testQueryEntityOne();
+ }
+
+ public void testCreateNoEntityTwo() throws Exception {
+ Database db = _category.getDatabase();
+ db.begin();
+ AutostoreMainMany main = new AutostoreMainMany();
+ main.setId(new Integer(100));
+ main.setName("main.100");
+ db.create(main);
+ db.commit();
+
+ db.begin();
+ main = (AutostoreMainMany) db.load(AutostoreMainMany.class, new Integer(100));
+ assertNotNull(main);
+ assertEquals(100, main.getId().intValue());
+ assertEquals("main.100", main.getName());
+ assertNotNull(main.getAssociatedMany());
+ assertEquals(0, main.getAssociatedMany().size());
+ db.commit();
+
+ db.begin();
+ main = (AutostoreMainMany) db.load(AutostoreMainMany.class, new Integer(100));
+ db.remove(main);
+ db.commit();
+
+ db.close();
+ }
+
+ public void testCreateWithEntityTwoNoAutoStore() throws Exception {
+ Database db = _category.getDatabase();
+ db.begin();
+ AutostoreAssociated1 entityTwo = new AutostoreAssociated1();
+ entityTwo.setId(new Integer(200));
+ entityTwo.setName("entity1.200");
+ AutostoreMain entityOne = new AutostoreMain();
+ entityOne.setId(new Integer(200));
+ entityOne.setName("entity2.200");
+ entityOne.setAssociatedOne(entityTwo);
+ db.create(entityOne);
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(200));
+ assertNotNull(entityOne);
+ assertEquals(200, entityOne.getId().intValue());
+ assertEquals("entity2.200", entityOne.getName());
+ assertNull(entityOne.getAssociatedOne());
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(200));
+ db.remove(entityOne);
+ db.commit();
+
+ db.close();
+ }
+
+ public void testCreateWithEntityTwoWithAutoStoreDeleteWithoutAutoStore()
+ throws Exception {
+ Database db = _category.getDatabase();
+ db.setAutoStore(true);
+
+ db.begin();
+ AutostoreAssociated1 entityTwo = new AutostoreAssociated1();
+ entityTwo.setId(new Integer(300));
+ entityTwo.setName("entity2.300");
+ AutostoreMain entityOne = new AutostoreMain();
+ entityOne.setId(new Integer(300));
+ entityOne.setName("entity1.300");
+ entityOne.setAssociatedOne(entityTwo);
+ db.create(entityOne);
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ assertNotNull(entityOne);
+ assertEquals(300, entityOne.getId().intValue());
+ assertEquals("entity1.300", entityOne.getName());
+ assertNotNull(entityOne.getAssociatedOne());
+ assertEquals(300, entityOne.getAssociatedOne().getId().intValue());
+ db.commit();
+
+ db.begin();
+ entityTwo = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ assertNotNull(entityTwo);
+ assertEquals(300, entityTwo.getId().intValue());
+ assertEquals("entity2.300", entityTwo.getName());
+ db.commit();
+
+ db.setAutoStore(false);
+
+ db.begin();
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ db.remove(entityOne);
+ db.commit();
+
+ db.begin();
+ entityTwo = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ assertNotNull(entityTwo);
+ assertEquals(300, entityTwo.getId().intValue());
+ assertEquals("entity2.300", entityTwo.getName());
+
+ try {
+ entityOne = (AutostoreMain) db.load(AutostoreMain.class, new Integer(300));
+ fail("Expected ObjectNotFoundException");
+ } catch (ObjectNotFoundException e) {
+ //
+ }
+ db.commit();
+
+ db.begin();
+ entityTwo = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ db.remove(entityTwo);
+ db.commit();
+
+ db.begin();
+ try {
+ entityTwo = (AutostoreAssociated1)
+ db.load(AutostoreAssociated1.class, new Integer(300));
+ fail("Expected ObjectNotFoundException");
+ } catch (ObjectNotFoundException e) {
+ //
+ }
+ db.commit();
+
+ db.close();
+ }
+
+ public void testCreateWithEntityTwoWithAutoStoreDeleteWithAutoStore()
+ throws Exception {
+ Database db = _category.getDatabase();
+ db.setAutoStore(true);
+
+ db.begin();
+ AutostoreAssociated1 entityTwo = new AutostoreAssociated1();
+ entityTwo.setId(new Integer(300));
+ entityTwo.setName("entity2.300");
+ List manys = new ArrayList();
+ manys.add(entityTwo);
+ AutostoreMainMany entityOne = new AutostoreMainMany();
+ entityOne.setId(new Integer(300));
+ entityOne.setName("entity1.300");
+ entityOne.setAssociatedMany(manys);
+ db.create(entityOne);
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMainMany) db.load(AutostoreMainMany.class, new Integer(300));
+ assertNotNull(entityOne);
+ assertEquals(300, entityOne.getId().intValue());
+ assertEquals("entity1.300", entityOne.getName());
+ assertNotNull(entityOne.getAssociatedMany());
+ assertEquals(1, entityOne.getAssociatedMany().size());
+
+ AutostoreAssociatedMany many = (AutostoreAssociatedMany) entityOne.getAssociatedMany().iterator().next();
+ assertEquals(300, many.getId().intValue());
+ db.commit();
+
+ db.begin();
+ many = (AutostoreAssociatedMany)
+ db.load(AutostoreAssociatedMany.class, new Integer(300));
+ assertNotNull(many);
+ assertEquals(300, many.getId().intValue());
+ assertEquals("entity2.300", many.getName());
+ db.commit();
+
+ db.begin();
+ entityOne = (AutostoreMainMany)
+ db.load(AutostoreMainMany.class, new Integer(300));
+ db.remove(entityOne);
+ db.commit();
+
+ db.begin();
+ try {
+ entityOne = (AutostoreMainMany)
+ db.load(AutostoreMainMany.class, new Integer(300));
+ fail("Expected ObjectNotFoundException");
+ } catch (ObjectNotFoundException e) {
+ //
+ }
+ try {
+ many = (AutostoreAssociatedMany)
+ db.load(AutostoreAssociatedMany.class, new Integer(300));
+ // TODO: remove once support for cascading delete has been added
+// fail("Expected ObjectNotFoundException");
+ } catch (ObjectNotFoundException e) {
+ //
+ }
+ db.commit();
+
+ // TODO: remove once support for cascading delete has been added
+ db.begin();
+ many = (AutostoreAssociatedMany)
+ db.load(AutostoreAssociatedMany.class, new Integer(300));
+ db.remove(many);
+ db.commit();
+
+ db.close();
+ }
+
+ /**
+ * Test method.
+ * @throws Exception For any exception thrown.
+ */
+ public void testQueryEntityOne() throws Exception {
+ Database db = _category.getDatabase();
+ db.begin();
+
+ OQLQuery query = db.getOQLQuery("SELECT entity FROM "
+ + AutostoreMainMany.class.getName() + " entity WHERE id = $1");
+ query.bind(new Integer(1));
+ QueryResults results = query.execute();
+
+ AutostoreMainMany entity = (AutostoreMainMany) results.next();
+
+ assertNotNull(entity);
+ assertEquals(new Integer(1), entity.getId());
+
+ List associatedManys = entity.getAssociatedMany();
+
+ assertNotNull(associatedManys);
+
+ Iterator iter = associatedManys.iterator();
+
+ assertTrue(iter.hasNext());
+ AutostoreAssociatedMany associatedMany = (AutostoreAssociatedMany)
+ iter.next();
+ assertEquals(new Integer(1), associatedMany.getId());
+
+ assertTrue(iter.hasNext());
+ associatedMany = (AutostoreAssociatedMany)
+ iter.next();
+ assertEquals(new Integer(2), associatedMany.getId());
+
+ assertFalse(iter.hasNext());
+
+ db.commit();
+ db.close();
+ }
+}
Index: tests/ctf/jdo/tc7x/AutostoreMain.java
===================================================================
--- tests/ctf/jdo/tc7x/AutostoreMain.java (Revision 0)
+++ tests/ctf/jdo/tc7x/AutostoreMain.java (Revision 0)
@@ -0,0 +1,31 @@
+package ctf.jdo.tc7x;
+
+public final class AutostoreMain {
+ private Integer _id;
+ private String _name;
+ private AutostoreAssociated1 _associatedOne;
+
+ public Integer getId() {
+ return _id;
+ }
+
+ public void setId(final Integer id) {
+ _id = id;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(final String name) {
+ _name = name;
+ }
+
+ public AutostoreAssociated1 getAssociatedOne() {
+ return _associatedOne;
+ }
+
+ public void setAssociatedOne(final AutostoreAssociated1 associatedOne) {
+ this._associatedOne = associatedOne;
+ }
+}
Index: tests/jdo/pointbase.sql
===================================================================
--- tests/jdo/pointbase.sql (Revision 5972)
+++ tests/jdo/pointbase.sql (Arbeitskopie)
@@ -541,7 +541,47 @@
-- grant all on tc7x_group_person to test;
+drop table tc7x_as_main;
+drop table tc7x_as_assoc1;
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_assoc1 primary key (id)
+);
+
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1');
+
+create table tc7x_as_main (
+ id int not null,
+ name varchar(200) not null,
+ assoc1_id int default null,
+ constraint pk_tc7x_as_main primary key (id)
+);
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1);
+
+drop table tc7x_as_assoc_many;
+drop table tc7x_as_main_many;
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_main_many primary key (id)
+);
+
+insert into tc7x_as_main_many (id, name) values (1, 'main');
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null,
+ constraint pk_tc7x_as_assoc_many primary key (id)
+);
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1);
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1);
+
+
-- test multiple pk
drop table tc8x_pks_person;
Index: tests/jdo/sybase.sql
===================================================================
--- tests/jdo/sybase.sql (Revision 5972)
+++ tests/jdo/sybase.sql (Arbeitskopie)
@@ -675,6 +675,60 @@
grant all on tc7x_group_person to test
go
+
+drop table tc7x_as_main
+go
+drop table tc7x_as_assoc1
+go
+
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_assoc1 primary key (id)
+)
+go
+
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1')
+go
+
+create table tc7x_as_main (
+ id int not null,
+ name varchar(200) not null,
+ assoc1_id int default null,
+ constraint pk_tc7x_as_main primary key (id)
+)
+go
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1)
+go
+
+drop table tc7x_as_assoc_many
+go
+drop table tc7x_as_main_many
+go
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_main_many primary key (id)
+)
+go
+
+insert into tc7x_as_main_many (id, name) values (1, 'main')
+go
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null,
+ constraint pk_tc7x_as_assoc_many primary key (id)
+)
+go
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1)
+go
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1)
+go
+
-- test multiple pk
drop table tc8x_pks_person
go
Index: tests/jdo/sapdb.sql
===================================================================
--- tests/jdo/sapdb.sql (Revision 5972)
+++ tests/jdo/sapdb.sql (Arbeitskopie)
@@ -658,7 +658,60 @@
create unique index tc7x_many_person_pk on tc7x_many_person ( pid )
//
+drop table tc7x_as_main
+//
+drop table tc7x_as_assoc1
+//
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_assoc1 primary key (id)
+)
+//
+
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1')
+//
+
+create table tc7x_as_main (
+ id int not null,
+ name varchar(200) not null,
+ assoc1_id int default null,
+ constraint pk_tc7x_as_main primary key (id)
+)
+//
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1)
+//
+
+drop table tc7x_as_assoc_many
+//
+drop table tc7x_as_main_many
+//
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_main_many primary key (id)
+)
+//
+
+insert into tc7x_as_main_many (id, name) values (1, 'main')
+//
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null,
+ constraint pk_tc7x_as_assoc_many primary key (id)
+)
+//
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1)
+//
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1)
+//
+
+
drop table tc8x_pks_person
//
Index: tests/jdo/mssql.sql
===================================================================
--- tests/jdo/mssql.sql (Revision 5972)
+++ tests/jdo/mssql.sql (Arbeitskopie)
@@ -668,6 +668,59 @@
grant all on to test
go
+drop table tc7x_as_main
+go
+drop table tc7x_as_assoc1
+go
+
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_assoc1 primary key (id)
+)
+go
+
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1')
+go
+
+create table tc7x_as_main (
+ id int not null primary key,
+ name varchar(200) not null,
+ assoc1_id int default null,
+ constraint pk_tc7x_as_main primary key (id)
+)
+go
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1)
+go
+
+drop table tc7x_as_assoc_many
+go
+drop table tc7x_as_main_many
+go
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_main_many primary key (id)
+)
+go
+
+insert into tc7x_as_main_many (id, name) values (1, 'main')
+go
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null,
+ constraint pk_tc7x_as_assoc_many primary key (id)
+)
+go
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1)
+go
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1)
+go
+
-- test multiple pk
drop table tc8x_pks_person
go
Index: tests/jdo/oracle.sql
===================================================================
--- tests/jdo/oracle.sql (Revision 5972)
+++ tests/jdo/oracle.sql (Arbeitskopie)
@@ -570,8 +570,47 @@
-- grant all on tc7x_group_person to test;
+drop table tc7x_as_main;
+drop table tc7x_as_assoc1;
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_assoc1 primary key (id)
+);
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1');
+
+create table tc7x_as_main (
+ id int not null,
+ name varchar(200) not null,
+ assoc1_id int default null,
+ constraint pk_tc7x_as_main primary key (id)
+);
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1);
+
+drop table tc7x_as_assoc_many;
+drop table tc7x_as_main_many;
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_main_many primary key (id)
+);
+
+insert into tc7x_as_main_many (id, name) values (1, 'main');
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null,
+ constraint pk_tc7x_as_assoc_many primary key (id)
+);
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1);
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1);
+
+
-- test multiple pk
drop table tc8x_pks_person;
Index: tests/jdo/mysql.sql
===================================================================
--- tests/jdo/mysql.sql (Revision 5972)
+++ tests/jdo/mysql.sql (Arbeitskopie)
@@ -604,7 +604,44 @@
insert into tc7x_sorted_item (id, id_1, name) values (2, 1, 'container item 2');
insert into tc7x_sorted_item (id, id_1, name) values (3, 2, 'container item 3');
+drop table if exists tc7x_as_main;
+drop table if exists tc7x_as_assoc1;
+create table tc7x_as_assoc1 (
+ id int not null primary key,
+ name varchar(200) not null
+);
+
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1');
+
+create table tc7x_as_main (
+ id int not null primary key,
+ name varchar(200) not null,
+ assoc1_id int null
+);
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1);
+
+drop table if exists tc7x_as_assoc_many;
+drop table if exists tc7x_as_main_many;
+create table tc7x_as_main_many (
+ id int not null primary key,
+ name varchar(200) not null
+);
+
+insert into tc7x_as_main_many (id, name) values (1, 'main');
+
+create table tc7x_as_assoc_many (
+ id int not null primary key,
+ name varchar(200) not null,
+ main_id int not null
+);
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1);
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1);
+
+-- tc8x
+
drop table if exists tc8x_pks_person;
create table tc8x_pks_person (
Index: tests/jdo/derby.sql
===================================================================
--- tests/jdo/derby.sql (Revision 5972)
+++ tests/jdo/derby.sql (Arbeitskopie)
@@ -540,8 +540,46 @@
-- grant all on tc7x_group_person to test;
+drop table tc7x_as_main;
+drop table tc7x_as_assoc1;
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_assoc1 primary key (id)
+);
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1');
+
+create table tc7x_as_main (
+ id int not null primary key,
+ name varchar(200) not null,
+ assoc1_id int default null,
+ constraint pk_tc7x_as_main primary key (id)
+);
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1);
+
+drop table tc7x_as_assoc_many;
+drop table tc7x_as_main_many;
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_main_many primary key (id)
+);
+
+insert into tc7x_as_main_many (id, name) values (1, 'main');
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null,
+ constraint pk_tc7x_as_assoc_many primary key (id)
+);
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1);
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1);
+
-- test multiple pk
drop table tc8x_pks_person;
Index: tests/jdo/postgres.sql
===================================================================
--- tests/jdo/postgres.sql (Revision 5972)
+++ tests/jdo/postgres.sql (Arbeitskopie)
@@ -592,6 +592,47 @@
create index test_oqltag_fk2 on test_oqltag( id2 );
+drop table tc7x_as_main;
+drop table tc7x_as_assoc1;
+
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_assoc1 primary key (id)
+);
+
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1');
+
+create table tc7x_as_main (
+ id int not null,
+ name varchar(200) not null,
+ assoc1_id int default null,
+ constraint pk_tc7x_as_main primary key (id)
+);
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1);
+
+drop table tc7x_as_assoc_many;
+drop table tc7x_as_main_many;
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_main_many primary key (id)
+);
+
+insert into tc7x_as_main_many (id, name) values (1, 'main');
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null,
+ constraint pk_tc7x_as_assoc_many primary key (id)
+);
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1);
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1);
+
+
drop table tc8x_pks_person;
create table tc8x_pks_person (
Index: tests/jdo/hsql.sql
===================================================================
--- tests/jdo/hsql.sql (Revision 5972)
+++ tests/jdo/hsql.sql (Arbeitskopie)
@@ -523,7 +523,46 @@
create unique index tc7x_many_person_pk on tc7x_many_person ( pid );
+drop table tc7x_as_main;
+drop table tc7x_as_assoc1;
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_assoc1 primary key (id)
+);
+
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1');
+
+create table tc7x_as_main (
+ id int not null,
+ name varchar(200) not null,
+ assoc1_id int default null,
+ constraint pk_tc7x_as_main primary key (id)
+);
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1);
+
+drop table tc7x_as_assoc_many;
+drop table tc7x_as_main_many;
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null,
+ constraint pk_tc7x_as_main_many primary key (id)
+);
+
+insert into tc7x_as_main_many (id, name) values (1, 'main');
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null,
+ constraint pk_tc7x_as_assoc_many primary key (id)
+);
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1);
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1);
+
drop table if exists tc8x_pks_person;
create table tc8x_pks_person (
Index: tests/jdo/db2.sql
===================================================================
--- tests/jdo/db2.sql (Revision 5972)
+++ tests/jdo/db2.sql (Arbeitskopie)
@@ -541,8 +541,44 @@
-- grant all on tc7x_group_person to test;
+drop table if exists tc7x_as_main;
+drop table if exists tc7x_as_assoc1;
+create table tc7x_as_assoc1 (
+ id int not null,
+ name varchar(200) not null
+);
+insert into tc7x_as_assoc1 (id, name) values (1, 'assoc1');
+
+create table tc7x_as_main (
+ id int not null,
+ name varchar(200) not null,
+ assoc1_id int default null
+);
+
+insert into tc7x_as_main (id, name, assoc1_id) values (1, 'main', 1);
+
+drop table if exists tc7x_as_assoc_many;
+drop table if exists tc7x_as_main_many;
+create table tc7x_as_main_many (
+ id int not null,
+ name varchar(200) not null
+);
+
+insert into tc7x_as_main_many (id, name) values (1, 'main');
+
+create table tc7x_as_assoc_many (
+ id int not null,
+ name varchar(200) not null,
+ main_id int not null
+);
+
+insert into tc7x_as_assoc_many (id, name, main_id) values (1, 'assoc.many.1', 1);
+insert into tc7x_as_assoc_many (id, name, main_id) values (2, 'assoc.many.2', 1);
+
+
+
-- test multiple pk
drop table tc8x_pks_person;