[jboss-cvs] JBossAS SVN: r75267 - in branches/Branch_4_2: testsuite/imports/sections and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 1 10:05:01 EDT 2008


Author: alex.loubyansky at jboss.com
Date: 2008-07-01 10:05:01 -0400 (Tue, 01 Jul 2008)
New Revision: 75267

Added:
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountBean.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountLocal.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountLocalHome.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerBean.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerLocal.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerLocalHome.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/Facade.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/FacadeBean.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/FacadeHome.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/test/
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/test/CascadeDeleteUnitTestCase.java
   branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/
   branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/
   branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/ejb-jar.xml
   branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/jboss.xml
   branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/jbosscmp-jdbc.xml
Modified:
   branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
   branches/Branch_4_2/testsuite/imports/sections/cmp.xml
Log:
JBAS-5696

Modified: branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
===================================================================
--- branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java	2008-07-01 14:00:45 UTC (rev 75266)
+++ branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -439,7 +439,7 @@
          System.arraycopy(tmp, 0, fkConstraints, 0, tmp.length);
       }
       final int fkindex = fkConstraints.length - 1;
-      final ForeignKeyConstraint fkc = new ForeignKeyConstraint(fkindex, fkFields);
+      final ForeignKeyConstraint fkc = new ForeignKeyConstraint(fkindex, fkFields, referenced.tableId == tableId);
       fkConstraints[fkindex] = fkc;
       return fkc;
    }
@@ -1340,38 +1340,35 @@
             for(int i = 0; i < rowsWithNullFks.size(); ++i)
             {
                final Row row = (Row) rowsWithNullFks.get(i);
-               if(row.state != DELETED)
+               final ForeignKeyConstraint[] cons = row.fkUpdates;
+               for (int c = 0; c < fkConstraints.length; ++c)
                {
-                  final ForeignKeyConstraint[] cons = row.fkUpdates;
-                  for(int c = 0; c < fkConstraints.length; ++c)
+                  if (cons[c] == null || row.state == DELETED && !cons[c].selfReference)
+                     continue;
+
+                  PreparedStatement s = ps[c];
+                  if (s == null)
                   {
-                     if(cons[c] != null)
+                     if (log.isDebugEnabled())
                      {
-                        PreparedStatement s = ps[c];
-                        if(s == null)
-                        {
-                           if(log.isDebugEnabled())
-                           {
-                              log.debug("nullifying fk: " + cons[c].nullFkSql);
-                           }
-                           s = con.prepareStatement(cons[c].nullFkSql);
-                           ps[c] = s;
-                        }
+                        log.debug("nullifying fk: " + cons[c].nullFkSql);
+                     }
+                     s = con.prepareStatement(cons[c].nullFkSql);
+                     ps[c] = s;
+                  }
 
-                        int paramInd = 1;
-                        for(int fInd = 0; fInd < pkFields.length; ++fInd)
-                        {
-                           JDBCCMPFieldBridge2 pkField = pkFields[fInd];
-                           Object fieldValue = row.fields[pkField.getRowIndex()];
-                           paramInd = pkField.setArgumentParameters(s, paramInd, fieldValue);
-                        }
+                  int paramInd = 1;
+                  for (int fInd = 0; fInd < pkFields.length; ++fInd)
+                  {
+                     JDBCCMPFieldBridge2 pkField = pkFields[fInd];
+                     Object fieldValue = row.fields[pkField.getRowIndex()];
+                     paramInd = pkField.setArgumentParameters(s, paramInd, fieldValue);
+                  }
 
-                        final int affected = s.executeUpdate();
-                        if(affected != 1)
-                        {
-                           throw new EJBException("Affected " + affected + " rows while expected just one");
-                        }
-                     }
+                  final int affected = s.executeUpdate();
+                  if (affected != 1)
+                  {
+                     throw new EJBException("Affected " + affected + " rows while expected just one");
                   }
                }
             }
@@ -1531,6 +1528,7 @@
          if(state == CREATED || state == DIRTY)
          {
             updateState(CLEAN);
+            fkUpdates = null;
          }
          else if(state == DELETED)
          {
@@ -1539,6 +1537,7 @@
          else if(state == DIRTY_RELATIONS)
          {
             updateState(CLEAN);
+            fkUpdates = null;
          }
 
          scheduleCacheUpdate();
@@ -1859,10 +1858,12 @@
    {
       public final int index;
       private final String nullFkSql;
+      private final boolean selfReference;
 
-      public ForeignKeyConstraint(int index, JDBCCMPFieldBridge2[] fkFields)
+      public ForeignKeyConstraint(int index, JDBCCMPFieldBridge2[] fkFields, boolean selfReference)
       {
          this.index = index;
+         this.selfReference = selfReference;
 
          StringBuffer buf = new StringBuffer();
          buf.append("update ").append(tableName).append(" set ")

Modified: branches/Branch_4_2/testsuite/imports/sections/cmp.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/cmp.xml	2008-07-01 14:00:45 UTC (rev 75266)
+++ branches/Branch_4_2/testsuite/imports/sections/cmp.xml	2008-07-01 14:05:01 UTC (rev 75267)
@@ -16,6 +16,22 @@
          <zipfileset src="${junit.junit.lib}/junit.jar"
             includes="junit/**/*.*"/>
       </jar>
+
+      <!-- build cmp2-cascadedelete.jar -->
+      <jar destfile="${build.lib}/cmp2-cascadedelete.jar">
+         <fileset dir="${build.classes}">
+            <patternset refid="common.test.client.classes"/>
+            <include name="org/jboss/test/cmp2/cascadedelete/ejb/**"/>
+         </fileset>
+         <fileset dir="${build.resources}/cmp2/cascadedelete">
+            <include name="**/*.*"/>
+         </fileset>
+         <zipfileset src="${jboss.test.lib}/jboss-test.jar"
+            includes="org/jboss/**/*.*"/>
+         <zipfileset src="${junit.junit.lib}/junit.jar"
+            includes="junit/**/*.*"/>
+      </jar>
+
       
       <!-- build cmp2-relationship.jar -->
       <jar destfile="${build.lib}/cmp2-relationship.jar">

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountBean.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountBean.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountBean.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import java.rmi.RemoteException;
+import java.util.Collection;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+
+/**
+ * A CustomerBean.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AccountBean implements EntityBean
+{
+   public Long ejbCreate(Long id, String name) throws CreateException
+   {
+      setId(id);
+      setName(name);
+      return null;
+   }
+   
+   public void ejbPostCreate(Long id, String name) throws CreateException
+   {
+   }
+   
+   public abstract Long getId();
+   public abstract void setId(Long id);
+
+   public abstract String getName();
+   public abstract void setName(String name);
+
+   public abstract CustomerLocal getCustomer();
+   public abstract void setCustomer(CustomerLocal customer);
+   
+   public abstract AccountLocal getParentAccount();
+   public abstract void setParentAccount(AccountLocal account);
+   
+   public abstract Collection getChildAccounts();
+   public abstract void setChildAccounts(Collection accounts);
+
+   public abstract AccountLocal getParentAccount2();
+   public abstract void setParentAccount2(AccountLocal account);
+   
+   public abstract Collection getChildAccounts2();
+   public abstract void setChildAccounts2(Collection accounts);
+
+   public void setEntityContext(EntityContext arg0) throws EJBException, RemoteException
+   {
+   }
+
+   public void unsetEntityContext() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbRemove() throws RemoveException, EJBException, RemoteException
+   {
+   }
+
+   public void ejbActivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbPassivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbLoad() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbStore() throws EJBException, RemoteException
+   {
+   }
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountLocal.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountLocal.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountLocal.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import java.util.Collection;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * A CustomerLocal.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface AccountLocal extends EJBLocalObject
+{
+   Long getId();
+   
+   String getName();
+   void setName(String name);
+   
+   CustomerLocal getCustomer();
+   void setCustomer(CustomerLocal customer);
+   
+   AccountLocal getParentAccount();
+   void setParentAccount(AccountLocal parent);
+   
+   Collection getChildAccounts();
+
+   AccountLocal getParentAccount2();
+   void setParentAccount2(AccountLocal parent);
+   
+   Collection getChildAccounts2();
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountLocalHome.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountLocalHome.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/AccountLocalHome.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.FinderException;
+
+/**
+ * A CustomerLocalHome.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface AccountLocalHome extends EJBLocalHome
+{
+   AccountLocal create(Long id, String name) throws CreateException;
+   
+   AccountLocal findByPrimaryKey(Long id) throws FinderException;
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerBean.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerBean.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerBean.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import java.rmi.RemoteException;
+import java.util.Collection;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+
+/**
+ * A CustomerBean.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class CustomerBean implements EntityBean
+{
+   public Long ejbCreate(Long id, String name) throws CreateException
+   {
+      setId(id);
+      setName(name);
+      return null;
+   }
+   
+   public void ejbPostCreate(Long id, String name) throws CreateException
+   {
+   }
+   
+   public abstract Long getId();
+   public abstract void setId(Long id);
+
+   public abstract String getName();
+   public abstract void setName(String name);
+
+   public abstract Collection getAccounts();
+   public abstract void setAccounts(Collection accounts);
+   
+   public void setEntityContext(EntityContext arg0) throws EJBException, RemoteException
+   {
+   }
+
+   public void unsetEntityContext() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbRemove() throws RemoveException, EJBException, RemoteException
+   {
+   }
+
+   public void ejbActivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbPassivate() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbLoad() throws EJBException, RemoteException
+   {
+   }
+
+   public void ejbStore() throws EJBException, RemoteException
+   {
+   }
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerLocal.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerLocal.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerLocal.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import java.util.Collection;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * A CustomerLocal.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CustomerLocal extends EJBLocalObject
+{
+   Long getId();
+   
+   String getName();
+   void setName(String name);
+   
+   Collection getAccounts();
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerLocalHome.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerLocalHome.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/CustomerLocalHome.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.FinderException;
+
+/**
+ * A CustomerLocalHome.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CustomerLocalHome extends EJBLocalHome
+{
+   CustomerLocal create(Long id, String name) throws CreateException;
+   
+   CustomerLocal findByPrimaryKey(Long id) throws FinderException;
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/Facade.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/Facade.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/Facade.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * A Facade.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Facade extends EJBObject
+{
+   void createScenario1() throws RemoteException;
+   void createScenario2() throws RemoteException;
+   void deleteBeans() throws RemoteException;
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/FacadeBean.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/FacadeBean.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/FacadeBean.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.InitialContext;
+import java.rmi.RemoteException;
+import java.util.Iterator;
+
+import javax.ejb.EJBException;
+
+
+/**
+ * A FacadeBean.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class FacadeBean implements SessionBean
+{
+   public void createScenario1() throws RemoteException
+   {
+      try
+      {
+         InitialContext ic = new InitialContext();
+         CustomerLocalHome ch = (CustomerLocalHome) ic.lookup("CustomerLocal");
+         CustomerLocal customer = ch.create(new Long(1), "customer1");
+
+         AccountLocalHome ah = (AccountLocalHome) ic.lookup("AccountLocal");
+         AccountLocal acc22 = ah.create(new Long(22), "account22");
+         acc22.setCustomer(customer);
+         
+         AccountLocal acc33 = ah.create(new Long(33), "account33");
+         acc33.setParentAccount(acc22);
+         acc33.setCustomer(customer);
+      }
+      catch (Exception e)
+      {
+         throw new EJBException("Failed to create scenario 1", e);
+      }
+   }
+
+   
+   public void createScenario2() throws RemoteException
+   {
+      try
+      {
+         InitialContext ic = new InitialContext();
+         CustomerLocalHome ch = (CustomerLocalHome) ic.lookup("CustomerLocal");
+         CustomerLocal customer = ch.create(new Long(1), "customer1");
+
+         AccountLocalHome ah = (AccountLocalHome) ic.lookup("AccountLocal");
+         AccountLocal acc11 = ah.create(new Long(11), "account11");
+         acc11.setCustomer(customer);
+
+         AccountLocal acc22 = ah.create(new Long(22), "account22");
+         acc22.setCustomer(customer);
+         acc11.setParentAccount(acc22);
+         
+         AccountLocal acc33 = ah.create(new Long(33), "account33");
+         acc33.setParentAccount(acc22);
+         acc33.setParentAccount2(acc11);
+         acc33.setCustomer(customer);
+      }
+      catch (Exception e)
+      {
+         throw new EJBException("Failed to create scenario 2", e);
+      }
+   }
+
+   public void deleteBeans() throws RemoteException
+   {
+      try
+      {
+         InitialContext ic = new InitialContext();
+         CustomerLocalHome ch = (CustomerLocalHome) ic.lookup("CustomerLocal");         
+         ch.remove(new Long(1));
+      }
+      catch(Exception e)
+      {
+         throw new EJBException(e);
+      }
+   }
+
+   public void ejbCreate() throws CreateException
+   {
+   }
+
+   public void setSessionContext(SessionContext ctx)
+   {
+   }
+
+   public void ejbActivate()
+   {
+   }
+
+   public void ejbPassivate()
+   {
+   }
+
+   public void ejbRemove()
+   {
+   }
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/FacadeHome.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/FacadeHome.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/ejb/FacadeHome.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.ejb;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * A FacadeHome.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public interface FacadeHome extends EJBHome
+{
+   Facade create() throws RemoteException, CreateException;
+}

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/test/CascadeDeleteUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/test/CascadeDeleteUnitTestCase.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/cascadedelete/test/CascadeDeleteUnitTestCase.java	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cmp2.cascadedelete.test;
+
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.cmp2.cascadedelete.ejb.Facade;
+import org.jboss.test.cmp2.cascadedelete.ejb.FacadeHome;
+
+
+/**
+ * A CascadeDeleteUnitTestCase.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class CascadeDeleteUnitTestCase extends JBossTestCase
+{
+   public CascadeDeleteUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return JBossTestCase.getDeploySetup(CascadeDeleteUnitTestCase.class, "cmp2-cascadedelete.jar");
+   }
+
+   public void testScenario1() throws Exception
+   {      
+      InitialContext ic = new InitialContext();
+      FacadeHome fh = (FacadeHome) PortableRemoteObject.narrow(ic.lookup("Facade"), FacadeHome.class);
+      Facade facade = fh.create();
+      facade.createScenario1();
+      facade.deleteBeans();
+   }
+
+   public void testScenario2() throws Exception
+   {      
+      InitialContext ic = new InitialContext();
+      FacadeHome fh = (FacadeHome) PortableRemoteObject.narrow(ic.lookup("Facade"), FacadeHome.class);
+      Facade facade = fh.create();
+      facade.createScenario2();
+      facade.deleteBeans();
+   }
+}

Added: branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/ejb-jar.xml	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/ejb-jar.xml	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar >
+
+   <description><![CDATA[No Description.]]></description>
+   <display-name>Generated by XDoclet</display-name>
+
+   <enterprise-beans>
+
+      <session>
+         <description>JUnit Session Bean Test Runner</description>
+         <ejb-name>EJBTestRunnerEJB</ejb-name>
+         <home>org.jboss.test.util.ejb.EJBTestRunnerHome</home>
+         <remote>org.jboss.test.util.ejb.EJBTestRunner</remote>
+         <ejb-class>org.jboss.test.util.ejb.EJBTestRunnerBean</ejb-class>
+         <session-type>Stateless</session-type>
+         <transaction-type>Bean</transaction-type>
+      </session>
+      <session>
+         <description>Facade</description>
+         <ejb-name>Facade</ejb-name>
+         <home>org.jboss.test.cmp2.cascadedelete.ejb.FacadeHome</home>
+         <remote>org.jboss.test.cmp2.cascadedelete.ejb.Facade</remote>
+         <ejb-class>org.jboss.test.cmp2.cascadedelete.ejb.FacadeBean</ejb-class>
+         <session-type>Stateless</session-type>
+         <transaction-type>Container</transaction-type>
+      </session>
+
+      <entity>
+         <description><![CDATA[Description for Customer]]></description>
+         <display-name>Customer</display-name>
+         <ejb-name>Customer</ejb-name>
+         <local-home>org.jboss.test.cmp2.cascadedelete.ejb.CustomerLocalHome</local-home>
+         <local>org.jboss.test.cmp2.cascadedelete.ejb.CustomerLocal</local>
+         <ejb-class>org.jboss.test.cmp2.cascadedelete.ejb.CustomerBean</ejb-class>
+         <persistence-type>Container</persistence-type>
+         <prim-key-class>java.lang.Long</prim-key-class>
+         <reentrant>False</reentrant>
+         <cmp-version>2.x</cmp-version>
+         <abstract-schema-name>Customer</abstract-schema-name>
+         <cmp-field >
+            <description><![CDATA[]]></description>
+            <field-name>id</field-name>
+         </cmp-field>
+         <cmp-field >
+            <description><![CDATA[]]></description>
+            <field-name>name</field-name>
+         </cmp-field>
+         <primkey-field>id</primkey-field>
+      </entity>
+      <entity>
+         <description><![CDATA[Description for Account]]></description>
+         <display-name>Account</display-name>
+         <ejb-name>Account</ejb-name>
+         <local-home>org.jboss.test.cmp2.cascadedelete.ejb.AccountLocalHome</local-home>
+         <local>org.jboss.test.cmp2.cascadedelete.ejb.AccountLocal</local>
+         <ejb-class>org.jboss.test.cmp2.cascadedelete.ejb.AccountBean</ejb-class>
+         <persistence-type>Container</persistence-type>
+         <prim-key-class>java.lang.Long</prim-key-class>
+         <reentrant>False</reentrant>
+         <cmp-version>2.x</cmp-version>
+         <abstract-schema-name>Account</abstract-schema-name>
+         <cmp-field >
+            <description><![CDATA[]]></description>
+            <field-name>id</field-name>
+         </cmp-field>
+         <cmp-field >
+            <description><![CDATA[]]></description>
+            <field-name>name</field-name>
+         </cmp-field>
+         <primkey-field>id</primkey-field>
+      </entity>
+   </enterprise-beans>
+
+   <!-- Relationships -->
+   <relationships >
+      <ejb-relation>
+         <ejb-relation-name>Customer-Account</ejb-relation-name>
+
+         <ejb-relationship-role >
+            <ejb-relationship-role-name>Account</ejb-relationship-role-name>
+            <multiplicity>Many</multiplicity>
+            <cascade-delete/>
+            <relationship-role-source >
+               <ejb-name>Account</ejb-name>
+            </relationship-role-source>
+            <cmr-field >
+               <cmr-field-name>customer</cmr-field-name>
+            </cmr-field>
+         </ejb-relationship-role>
+
+         <ejb-relationship-role >
+            <ejb-relationship-role-name>Customer</ejb-relationship-role-name>
+            <multiplicity>One</multiplicity>
+            <relationship-role-source >
+               <ejb-name>Customer</ejb-name>
+            </relationship-role-source>
+            <cmr-field >
+               <cmr-field-name>accounts</cmr-field-name>
+            </cmr-field>
+         </ejb-relationship-role>
+
+      </ejb-relation>
+      <ejb-relation>
+         <ejb-relation-name>ParentAccount-ChildAccounts</ejb-relation-name>
+
+         <ejb-relationship-role >
+            <ejb-relationship-role-name>Children</ejb-relationship-role-name>
+            <multiplicity>Many</multiplicity>
+            <relationship-role-source >
+               <ejb-name>Account</ejb-name>
+            </relationship-role-source>
+            <cmr-field >
+               <cmr-field-name>parentAccount</cmr-field-name>
+            </cmr-field>
+         </ejb-relationship-role>
+
+         <ejb-relationship-role >
+            <ejb-relationship-role-name>Parent</ejb-relationship-role-name>
+            <multiplicity>One</multiplicity>
+            <relationship-role-source >
+               <ejb-name>Account</ejb-name>
+            </relationship-role-source>
+            <cmr-field >
+               <cmr-field-name>childAccounts</cmr-field-name>
+            </cmr-field>
+         </ejb-relationship-role>
+
+      </ejb-relation>
+      <ejb-relation>
+         <ejb-relation-name>ParentAccount-ChildAccounts2</ejb-relation-name>
+
+         <ejb-relationship-role >
+            <ejb-relationship-role-name>Children</ejb-relationship-role-name>
+            <multiplicity>Many</multiplicity>
+            <relationship-role-source >
+               <ejb-name>Account</ejb-name>
+            </relationship-role-source>
+            <cmr-field >
+               <cmr-field-name>parentAccount2</cmr-field-name>
+            </cmr-field>
+         </ejb-relationship-role>
+
+         <ejb-relationship-role >
+            <ejb-relationship-role-name>Parent</ejb-relationship-role-name>
+            <multiplicity>One</multiplicity>
+            <relationship-role-source >
+               <ejb-name>Account</ejb-name>
+            </relationship-role-source>
+            <cmr-field >
+               <cmr-field-name>childAccounts2</cmr-field-name>
+            </cmr-field>
+         </ejb-relationship-role>
+
+      </ejb-relation>
+   </relationships>
+
+</ejb-jar>

Added: branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/jboss.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/jboss.xml	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/jboss.xml	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
+
+<jboss>
+
+   <enterprise-beans>
+
+      <entity>
+         <ejb-name>Customer</ejb-name>
+         <local-jndi-name>CustomerLocal</local-jndi-name>
+         <configuration-name>custom container</configuration-name>
+      </entity>
+      <entity>
+         <ejb-name>Account</ejb-name>
+         <local-jndi-name>AccountLocal</local-jndi-name>
+         <configuration-name>custom container</configuration-name>
+      </entity>
+
+      <session>
+         <ejb-name>EJBTestRunnerEJB</ejb-name>
+         <jndi-name>ejb/EJBTestRunner</jndi-name>
+      </session>
+      <session>
+         <ejb-name>Facade</ejb-name>
+         <jndi-name>Facade</jndi-name>
+      </session>
+
+   </enterprise-beans>
+
+   <container-configurations>
+
+    <container-configuration extends="cmp2.x jdbc2 pm">
+      <container-name>custom container</container-name>
+    </container-configuration>
+
+   </container-configurations>
+
+</jboss>

Added: branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/jbosscmp-jdbc.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/jbosscmp-jdbc.xml	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cmp2/cascadedelete/META-INF/jbosscmp-jdbc.xml	2008-07-01 14:05:01 UTC (rev 75267)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
+
+<jbosscmp-jdbc>
+   <enterprise-beans>
+
+      <entity>
+         <ejb-name>Customer</ejb-name>
+         <create-table>true</create-table>
+         <remove-table>true</remove-table>
+         <table-name>Customer</table-name>
+         <cmp-field>
+            <field-name>id</field-name>
+            <column-name>id</column-name>
+        </cmp-field>
+         <cmp-field>
+            <field-name>name</field-name>
+            <column-name>name</column-name>
+        </cmp-field>
+      </entity>
+
+      <entity>
+         <ejb-name>Account</ejb-name>
+         <create-table>true</create-table>
+         <remove-table>true</remove-table>
+         <table-name>Account</table-name>
+         <cmp-field>
+            <field-name>id</field-name>
+            <column-name>id</column-name>
+        </cmp-field>
+         <cmp-field>
+            <field-name>name</field-name>
+            <column-name>name</column-name>
+        </cmp-field>
+      </entity>
+
+   </enterprise-beans>
+
+  <relationships>
+    <ejb-relation>
+      <ejb-relation-name>Customer-Account</ejb-relation-name>
+
+      <ejb-relationship-role>
+          <ejb-relationship-role-name>Account</ejb-relationship-role-name>
+          <fk-constraint>true</fk-constraint>
+		  <key-fields/>
+      </ejb-relationship-role>
+      <ejb-relationship-role>
+          <ejb-relationship-role-name>Customer</ejb-relationship-role-name>
+          <key-fields>
+             <key-field>
+               <field-name>id</field-name>
+               <column-name>customerId</column-name>
+             </key-field>
+          </key-fields>
+
+      </ejb-relationship-role>
+    </ejb-relation>
+    <ejb-relation>
+      <ejb-relation-name>ParentAccount-ChildAccounts</ejb-relation-name>
+
+      <ejb-relationship-role>
+          <ejb-relationship-role-name>Children</ejb-relationship-role-name>
+          <fk-constraint>true</fk-constraint>
+		  <key-fields/>
+
+      </ejb-relationship-role>
+      <ejb-relationship-role>
+          <ejb-relationship-role-name>Parent</ejb-relationship-role-name>
+          <key-fields>
+             <key-field>
+               <field-name>id</field-name>
+               <column-name>parentId</column-name>
+             </key-field>
+          </key-fields>
+
+      </ejb-relationship-role>
+    </ejb-relation>
+    <ejb-relation>
+      <ejb-relation-name>ParentAccount-ChildAccounts2</ejb-relation-name>
+
+      <ejb-relationship-role>
+          <ejb-relationship-role-name>Children</ejb-relationship-role-name>
+          <fk-constraint>true</fk-constraint>
+		  <key-fields/>
+
+      </ejb-relationship-role>
+      <ejb-relationship-role>
+          <ejb-relationship-role-name>Parent</ejb-relationship-role-name>
+          <key-fields>
+             <key-field>
+               <field-name>id</field-name>
+               <column-name>parent2Id</column-name>
+             </key-field>
+          </key-fields>
+
+      </ejb-relationship-role>
+    </ejb-relation>
+  </relationships>
+
+</jbosscmp-jdbc>




More information about the jboss-cvs-commits mailing list