gdamour 2004/11/11 08:27:45
Modified:
modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany
ALocal.java OneToManyCompoundPKTest.java
OneToManyTest.java
Added:
modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany
OneToManyCascadeDeleteTest.java
OneToManyCompoundPKCascadeDeleteTest.java
Log:
GERONIMO-467: ejbRemove does not work for CMP with MTM relationship
GERONIMO-468: CMP - cascade delete is not supported
o update CMPRemoveMethod such that relationships are reset and EJB in
cascade-delete relationships are also removed; and
o update the way the various TranQL schema are built in order to retrieve
the EJB defining a cascade-delete relationship.
Revision Changes Path
1.2 +2 -1
openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/ALocal.java
Index: ALocal.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/ALocal.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ALocal.java 10 Nov 2004 01:35:11 -0000 1.1
+++ ALocal.java 11 Nov 2004 13:27:45 -0000 1.2
@@ -66,4 +66,5 @@
// CMR
public Set getB();
public void setB(Set bSet);
+
}
1.2 +25 -1
openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyCompoundPKTest.java
Index: OneToManyCompoundPKTest.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyCompoundPKTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- OneToManyCompoundPKTest.java 10 Nov 2004 01:35:11 -0000 1.1
+++ OneToManyCompoundPKTest.java 11 Nov 2004 13:27:45 -0000 1.2
@@ -273,6 +273,30 @@
assertStateExistingANewB();
}
+ /**
+ * TODO Disabled due to an Axion bug. It has been tested with another
+ * DB DataSource successfully.
+ */
+ public void XtestRemoveRelationships() throws Exception {
+ ContainerTransactionContext ctx = newTransactionContext();
+ ALocal a = ahome.findByPrimaryKey(new CompoundPK(new Integer(1),
"value1"));
+ a.remove();
+ ctx.commit();
+
+ Connection c = ds.getConnection();
+ Statement s = c.createStatement();
+ ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM B");
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ rs.close();
+ rs = s.executeQuery("SELECT COUNT(*) FROM B WHERE fka1 = 1 AND fka2
= 'value1'");
+ assertTrue(rs.next());
+ assertEquals(0, rs.getInt(1));
+ rs.close();
+ s.close();
+ c.close();
+ }
+
protected void setUp() throws Exception {
super.setUp();
1.2 +25 -1
openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyTest.java
Index: OneToManyTest.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- OneToManyTest.java 10 Nov 2004 01:35:11 -0000 1.1
+++ OneToManyTest.java 11 Nov 2004 13:27:45 -0000 1.2
@@ -267,6 +267,30 @@
assertStateExistingANewB();
}
+ /**
+ * TODO Disabled due to an Axion bug. It has been tested with another
+ * DB DataSource successfully.
+ */
+ public void XtestRemoveRelationships() throws Exception {
+ ContainerTransactionContext ctx = newTransactionContext();
+ ALocal a = ahome.findByPrimaryKey(new Integer(1));
+ a.remove();
+ ctx.commit();
+
+ Connection c = ds.getConnection();
+ Statement s = c.createStatement();
+ ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM B");
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ rs.close();
+ rs = s.executeQuery("SELECT COUNT(*) FROM B WHERE fka1 = 1");
+ assertTrue(rs.next());
+ assertEquals(0, rs.getInt(1));
+ rs.close();
+ s.close();
+ c.close();
+ }
+
protected void setUp() throws Exception {
super.setUp();
1.1
openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyCascadeDeleteTest.java
Index: OneToManyCascadeDeleteTest.java
===================================================================
/* ====================================================================
* 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 this list of
* conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name "OpenEJB" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of The OpenEJB Group. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "OpenEJB"
* nor may "OpenEJB" appear in their names without prior written
* permission of The OpenEJB Group. OpenEJB is a registered
* trademark of The OpenEJB Group.
*
* 5. Due credit should be given to the OpenEJB Project
* (http://openejb.org/).
*
* THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP 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
* THE OPENEJB GROUP 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.
*
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the OpenEJB Project. For more information
* please see <http://openejb.org/>.
*
* ====================================================================
*/
package org.openejb.deployment.entity.cmp.cmr.onetomany;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.geronimo.transaction.context.ContainerTransactionContext;
import org.openejb.deployment.entity.cmp.cmr.AbstractCMRTest;
import org.openejb.deployment.entity.cmp.cmr.CompoundPK;
/**
*
* @version $Revision: 1.1 $ $Date: 2004/11/11 13:27:45 $
*/
public class OneToManyCascadeDeleteTest extends AbstractCMRTest {
private ALocalHome ahome;
private ALocal a;
private BLocalHome bhome;
private BLocal b;
public void testCascadeDelete() throws Exception {
ContainerTransactionContext ctx = newTransactionContext();
ALocal a = ahome.findByPrimaryKey(new CompoundPK(new Integer(1),
"value1"));
a.remove();
ctx.commit();
Connection c = ds.getConnection();
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM B");
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
rs.close();
s.close();
c.close();
}
protected void setUp() throws Exception {
super.setUp();
ahome = (ALocalHome) super.ahome;
bhome = (BLocalHome) super.bhome;
}
protected void buildDBSchema(Connection c) throws Exception {
Statement s = c.createStatement();
try {
s.execute("DROP TABLE A");
} catch (SQLException e) {
// ignore
}
try {
s.execute("DROP TABLE B");
} catch (SQLException e) {
// ignore
}
s.execute("CREATE TABLE A(A1 INTEGER, A2 VARCHAR(50))");
s.execute("CREATE TABLE B(B1 INTEGER, B2 VARCHAR(50), FKA1 INTEGER,
FKA2 VARCHAR(50))");
s.execute("INSERT INTO A(A1, A2) VALUES(1, 'value1')");
s.execute("INSERT INTO B(B1, B2, FKA1, FKA2) VALUES(11, 'value11', 1,
'value1')");
s.execute("INSERT INTO B(B1, B2, FKA1, FKA2) VALUES(22, 'value22', 1,
'value1')");
s.close();
c.close();
}
protected String getEjbJarDD() {
return "src/test-cmp/onetomany/compoundpk/cascade-delete-ejb-jar.xml";
}
protected String getOpenEjbJarDD() {
return "src/test-cmp/onetomany/compoundpk/openejb-jar.xml";
}
protected EJBClass getA() {
return new EJBClass(ABean.class, ALocalHome.class, ALocal.class);
}
protected EJBClass getB() {
return new EJBClass(BBean.class, BLocalHome.class, BLocal.class);
}
}
1.1
openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyCompoundPKCascadeDeleteTest.java
Index: OneToManyCompoundPKCascadeDeleteTest.java
===================================================================
/* ====================================================================
* 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 this list of
* conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name "OpenEJB" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of The OpenEJB Group. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "OpenEJB"
* nor may "OpenEJB" appear in their names without prior written
* permission of The OpenEJB Group. OpenEJB is a registered
* trademark of The OpenEJB Group.
*
* 5. Due credit should be given to the OpenEJB Project
* (http://openejb.org/).
*
* THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP 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
* THE OPENEJB GROUP 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.
*
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the OpenEJB Project. For more information
* please see <http://openejb.org/>.
*
* ====================================================================
*/
package org.openejb.deployment.entity.cmp.cmr.onetomany;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.geronimo.transaction.context.ContainerTransactionContext;
import org.openejb.deployment.entity.cmp.cmr.AbstractCMRTest;
import org.openejb.deployment.entity.cmp.cmr.CompoundPK;
/**
*
* @version $Revision: 1.1 $ $Date: 2004/11/11 13:27:45 $
*/
public class OneToManyCompoundPKCascadeDeleteTest extends AbstractCMRTest {
private ALocalHome ahome;
private ALocal a;
private BLocalHome bhome;
private BLocal b;
public void testCascadeDelete() throws Exception {
ContainerTransactionContext ctx = newTransactionContext();
ALocal a = ahome.findByPrimaryKey(new CompoundPK(new Integer(1),
"value1"));
a.remove();
ctx.commit();
Connection c = ds.getConnection();
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM B");
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
rs.close();
s.close();
c.close();
}
protected void setUp() throws Exception {
super.setUp();
ahome = (ALocalHome) super.ahome;
bhome = (BLocalHome) super.bhome;
}
protected void buildDBSchema(Connection c) throws Exception {
Statement s = c.createStatement();
try {
s.execute("DROP TABLE A");
} catch (SQLException e) {
// ignore
}
try {
s.execute("DROP TABLE B");
} catch (SQLException e) {
// ignore
}
s.execute("CREATE TABLE A(A1 INTEGER, A2 VARCHAR(50))");
s.execute("CREATE TABLE B(B1 INTEGER, B2 VARCHAR(50), FKA1 INTEGER,
FKA2 VARCHAR(50))");
s.execute("INSERT INTO A(A1, A2) VALUES(1, 'value1')");
s.execute("INSERT INTO B(B1, B2, FKA1, FKA2) VALUES(11, 'value11', 1,
'value1')");
s.execute("INSERT INTO B(B1, B2, FKA1, FKA2) VALUES(22, 'value22', 1,
'value1')");
s.close();
c.close();
}
protected String getEjbJarDD() {
return "src/test-cmp/onetomany/compoundpk/cascade-delete-ejb-jar.xml";
}
protected String getOpenEjbJarDD() {
return "src/test-cmp/onetomany/compoundpk/openejb-jar.xml";
}
protected EJBClass getA() {
return new EJBClass(ABean.class, ALocalHome.class, ALocal.class);
}
protected EJBClass getB() {
return new EJBClass(BBean.class, BLocalHome.class, BLocal.class);
}
}