You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2008/11/01 00:49:29 UTC

svn commit: r709602 [7/8] - in /ode/branches/APACHE_ODE_1.X: ./ axis2-war/src/main/webapp/WEB-INF/conf.hib-derby/ axis2-war/src/main/webapp/WEB-INF/conf.jpa-derby/ axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/ axis2-war/src/test/java/or...

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java Fri Oct 31 16:49:23 2008
@@ -36,6 +36,7 @@
 import org.apache.ode.bpel.iapi.MessageExchange;
 import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
 import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
 import org.apache.ode.bpel.intercept.AbortMessageExchangeException;
 import org.apache.ode.bpel.intercept.FaultMessageExchangeException;
 import org.apache.ode.bpel.intercept.InterceptorInvoker;
@@ -104,6 +105,7 @@
         return true;
     }
 
+    @SuppressWarnings("unchecked")
     public Future invoke(Message request) {
         if (request == null) {
             String errmsg = "Must pass non-null message to invoke()!";
@@ -183,6 +185,12 @@
     public boolean isAsynchronous() {
         return true;
     }
+
+    public void release(boolean instanceSucceeded) {
+        if(__log.isDebugEnabled()) __log.debug("Releasing mex " + getMessageExchangeId());
+        _dao.release(_process.isCleanupCategoryEnabled(instanceSucceeded, CLEANUP_CATEGORY.MESSAGES));
+        _dao = null;
+    }
     
     /**
      * Return a deep clone of the given message
@@ -204,7 +212,7 @@
 		return clone;
 	}
     
-
+	@SuppressWarnings("unchecked")
     static class ResponseFuture implements Future {
         private String _clientId;
         private boolean _done = false;

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java Fri Oct 31 16:49:23 2008
@@ -61,6 +61,7 @@
 import org.apache.ode.bpel.iapi.ProcessConf;
 import org.apache.ode.bpel.iapi.ProcessState;
 import org.apache.ode.bpel.iapi.ProcessStore;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
 import org.apache.ode.bpel.o.OBase;
 import org.apache.ode.bpel.o.OPartnerLink;
 import org.apache.ode.bpel.o.OProcess;
@@ -124,6 +125,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
+import java.util.EnumSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -424,7 +426,11 @@
                 public Object run(BpelDAOConnection conn) {
                     Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter);
                     for (ProcessInstanceDAO instance : instances) {
-                        instance.delete();
+						ProcessConf proc = _store.getProcessConfiguration(instance.getProcess().getProcessId());
+						if (proc == null)
+						    throw new ProcessNotFoundException("ProcessNotFound:" + instance.getProcess().getProcessId());
+						// delete the instance and all related data
+                        instance.delete(EnumSet.allOf(CLEANUP_CATEGORY.class));
                         ret.add(instance.getInstanceId());
                     }
                     return null;

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java Fri Oct 31 16:49:23 2008
@@ -90,6 +90,7 @@
         return null;
     }
 
+    @SuppressWarnings("unchecked")
     public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter filter) {
         if(filter.getLimit()==0) {
             return Collections.EMPTY_LIST;

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java Fri Oct 31 16:49:23 2008
@@ -284,7 +284,7 @@
 		++subscriberCount;
 	}
 	
-    public void release() {
+    public void release(boolean doClean) {
         instance = null;
         process = null;
         _plink = null;

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java Fri Oct 31 16:49:23 2008
@@ -24,11 +24,13 @@
 import org.apache.ode.bpel.dao.CorrelationSetDAO;
 import org.apache.ode.bpel.dao.CorrelatorDAO;
 import org.apache.ode.bpel.dao.FaultDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
 import org.apache.ode.bpel.dao.ProcessDAO;
 import org.apache.ode.bpel.dao.ProcessInstanceDAO;
 import org.apache.ode.bpel.dao.ScopeDAO;
 import org.apache.ode.bpel.dao.XmlDataDAO;
 import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
 import org.apache.ode.utils.QNameUtils;
 import org.w3c.dom.Element;
 
@@ -277,7 +279,7 @@
         this.getProcess().instanceCompleted(this);
     }
 
-    public void delete() {
+    public void delete(Set<CLEANUP_CATEGORY> cleanupCategories) {
         _processDao._instances.remove(_instanceId);
     }
 

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java Fri Oct 31 16:49:23 2008
@@ -250,7 +250,7 @@
 
     String getSourceSessionId(String mexId);
 
-    void releasePartnerMex(String mexId);
+    void releasePartnerMex(String mexId, boolean instanceSucceeded);
 
     /**
      * Read an external variable. 

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/INVOKE.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/INVOKE.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/INVOKE.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/INVOKE.java Fri Oct 31 16:49:23 2008
@@ -161,7 +161,7 @@
                         // TODO update output variable with data from non-initiate correlation sets
 
                         _self.parent.completed(fault, CompensationHandler.emptySet());
-                        getBpelRuntimeContext().releasePartnerMex(mexId);
+                        getBpelRuntimeContext().releasePartnerMex(mexId, fault == null);
                     }
 
                     public void onFault() {
@@ -171,7 +171,7 @@
                         FaultData fault = createFault(faultName, msg,
                                 _oinvoke.getOwner().messageTypes.get(msgType), _self.o);
                         _self.parent.completed(fault, CompensationHandler.emptySet());
-                        getBpelRuntimeContext().releasePartnerMex(mexId);
+                        getBpelRuntimeContext().releasePartnerMex(mexId, false);
                     }
 
                     public void onFailure() {
@@ -187,7 +187,8 @@
                         } catch (Exception e) {
                             _self.parent.failure(reason, null);
                         }
-                        getBpelRuntimeContext().releasePartnerMex(mexId);
+                        // Resuming the process creates a new invoke
+                        getBpelRuntimeContext().releasePartnerMex(mexId, false);
                     }
 
                 }.or(new TerminationChannelListener(_self.self) {

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java Fri Oct 31 16:49:23 2008
@@ -410,7 +410,7 @@
       return null;
     }
 
-    public void releasePartnerMex(String mexId) {
+    public void releasePartnerMex(String mexId, boolean instanceSucceeded) {
         // TODO Auto-generated method stub
         
     }

Modified: ode/branches/APACHE_ODE_1.X/bpel-schemas/src/main/xsd/dd.xsd
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-schemas/src/main/xsd/dd.xsd?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-schemas/src/main/xsd/dd.xsd (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-schemas/src/main/xsd/dd.xsd Fri Oct 31 16:49:23 2008
@@ -93,6 +93,9 @@
                             </xs:annotation>
                         </xs:element>
 
+           				<xs:element name="cleanup"
+           					minOccurs="0" maxOccurs="3"
+           					type="dd:tCleanup" />
                     </xs:sequence>
 
                     <xs:attribute name="name" type="xs:QName" use="required"/>
@@ -189,4 +192,29 @@
         </xs:complexContent>
     </xs:complexType>
 
+    <xs:complexType name="tCleanup">
+    	<xs:sequence>
+    		<xs:element name="category" default="all" minOccurs="0" maxOccurs="unbounded">
+    			<xs:simpleType>
+    				<xs:restriction base="xs:string">
+    					<xs:enumeration value="instance" />
+    					<xs:enumeration value="variables" />
+    					<xs:enumeration value="messages" />
+    					<xs:enumeration value="correlations" />
+    					<xs:enumeration value="events" />
+    					<xs:enumeration value="all" />
+    				</xs:restriction>
+    			</xs:simpleType>
+    		</xs:element>
+    	</xs:sequence>
+    	<xs:attribute name="on" use="required">
+    		<xs:simpleType>
+    			<xs:restriction base="xs:string">
+    				<xs:enumeration value="success" />
+    				<xs:enumeration value="failure" />
+    				<xs:enumeration value="always" />
+    			</xs:restriction>
+    		</xs:simpleType>
+    	</xs:attribute>
+    </xs:complexType>
 </xs:schema>

Added: ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessCleanupConfImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessCleanupConfImpl.java?rev=709602&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessCleanupConfImpl.java (added)
+++ ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessCleanupConfImpl.java Fri Oct 31 16:49:23 2008
@@ -0,0 +1,71 @@
+package org.apache.ode.store;
+
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.dd.TCleanup;
+import org.apache.ode.bpel.dd.TDeployment;
+import org.apache.ode.bpel.iapi.ContextException;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+
+public class ProcessCleanupConfImpl {
+	protected static Log __log = LogFactory.getLog(ProcessCleanupConfImpl.class);
+	
+	private final Set<CLEANUP_CATEGORY> successCategories = EnumSet.noneOf(CLEANUP_CATEGORY.class);
+	private final Set<CLEANUP_CATEGORY> failureCategories = EnumSet.noneOf(CLEANUP_CATEGORY.class);
+	
+	// package default
+    ProcessCleanupConfImpl(TDeployment.Process pinfo) {
+		for( TCleanup cleanup : pinfo.getCleanupList() ) {
+			if( cleanup.getOn() == TCleanup.On.SUCCESS || cleanup.getOn() == TCleanup.On.ALWAYS ) {
+				processACleanup(successCategories, cleanup.getCategoryList());
+			}
+			if( cleanup.getOn() == TCleanup.On.FAILURE || cleanup.getOn() == TCleanup.On.ALWAYS ) {
+				processACleanup(failureCategories, cleanup.getCategoryList());
+			}
+		}
+		
+		// validate configurations
+		Set<CLEANUP_CATEGORY> categories = getCleanupCategories(true);
+		if( categories.contains(CLEANUP_CATEGORY.INSTANCE) && !categories.containsAll(EnumSet.of(CLEANUP_CATEGORY.CORRELATIONS, CLEANUP_CATEGORY.VARIABLES))) {
+			throw new ContextException("Cleanup configuration error: the instance category requires both the correlations and variables categories specified together!!!");
+		}
+		categories = getCleanupCategories(false);
+		if( categories.contains(CLEANUP_CATEGORY.INSTANCE) && !categories.containsAll(EnumSet.of(CLEANUP_CATEGORY.CORRELATIONS, CLEANUP_CATEGORY.VARIABLES))) {
+			throw new ContextException("Cleanup configuration error: the instance category requires both the correlations and variables categories specified together!!!");
+		}
+    }
+
+    private void processACleanup(Set<CLEANUP_CATEGORY> categories, List<TCleanup.Category.Enum> categoryList) {
+		if( categoryList.isEmpty() ) {
+			// add all categories
+			categories.addAll(EnumSet.allOf(CLEANUP_CATEGORY.class));
+		} else {
+			for( TCleanup.Category.Enum aCategory : categoryList ) {
+				if( aCategory == TCleanup.Category.ALL) {
+					// add all categories
+					categories.addAll(EnumSet.allOf(CLEANUP_CATEGORY.class));
+				} else {
+					categories.add(CLEANUP_CATEGORY.fromString(aCategory.toString()));
+				}
+			}
+		}
+    }
+    
+    // package default
+    boolean isCleanupCategoryEnabled(boolean instanceSucceeded, CLEANUP_CATEGORY category) {
+    	if( instanceSucceeded ) {
+    		return successCategories.contains(category);
+    	} else {
+    		return failureCategories.contains(category);
+    	}
+    }
+    
+    // package default
+    Set<CLEANUP_CATEGORY> getCleanupCategories(boolean instanceSucceeded) {
+    	return instanceSucceeded ? successCategories : failureCategories;
+    }
+}

Modified: ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java Fri Oct 31 16:49:23 2008
@@ -101,6 +101,8 @@
 
     private EndpointReferenceContext eprContext;
 
+    private final ProcessCleanupConfImpl processCleanupConfImpl;
+    
     ProcessConfImpl(QName pid, QName type, long version, DeploymentUnitDir du, TDeployment.Process pinfo, Date deployDate,
                     Map<QName, Node> props, ProcessState pstate, EndpointReferenceContext eprContext, File configDir) {
         _pid = pid;
@@ -120,6 +122,8 @@
         initLinks();
         initMexInterceptors();
         initEventList();
+        
+        processCleanupConfImpl = new ProcessCleanupConfImpl(pinfo);
     }
 
     private List<File> collectEndpointConfigFiles() {
@@ -484,5 +488,11 @@
         }
     }
 
-
+    public boolean isCleanupCategoryEnabled(boolean instanceSucceeded, CLEANUP_CATEGORY category) {
+    	return processCleanupConfImpl.isCleanupCategoryEnabled(instanceSucceeded, category);
+    }
+    
+    public Set<CLEANUP_CATEGORY> getCleanupCategories(boolean instanceSucceeded) {
+    	return processCleanupConfImpl.getCleanupCategories(instanceSucceeded);
+    }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/hib/DeploymentUnitDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/hib/DeploymentUnitDaoImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/hib/DeploymentUnitDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/hib/DeploymentUnitDaoImpl.java Fri Oct 31 16:49:23 2008
@@ -54,7 +54,7 @@
      *  cascade="all"
      *  role="store_processes"
      * @hibernate.collection-key
-     *  column="DU"
+     *  column="DU" foreign-key="none"
      * @hibernate.collection-one-to-many
      *  class="org.apache.ode.store.hib.ProcessConfDaoImpl"
      */

Modified: ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/hib/ProcessConfDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/hib/ProcessConfDaoImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/hib/ProcessConfDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/hib/ProcessConfDaoImpl.java Fri Oct 31 16:49:23 2008
@@ -54,7 +54,7 @@
 
 
     /**
-     * @hibernate.many-to-one 
+     * @hibernate.many-to-one foreign-key="none"
      * @hibernate.column name="DU"
      */
     public DeploymentUnitDaoImpl getDeploymentUnit() {
@@ -66,7 +66,7 @@
     }
     /**
      * @hibernate.map table="STORE_PROCESS_PROP" role="properties_"
-     * @hibernate.collection-key column="propId" 
+     * @hibernate.collection-key column="propId" foreign-key="none"
      * @hibernate.collection-index column="name" type="string" 
      * @hibernate.collection-element column="value" type="string"
      */

Modified: ode/branches/APACHE_ODE_1.X/bpel-store/src/test/java/org/apache/ode/store/ProcessStoreTest.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-store/src/test/java/org/apache/ode/store/ProcessStoreTest.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-store/src/test/java/org/apache/ode/store/ProcessStoreTest.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-store/src/test/java/org/apache/ode/store/ProcessStoreTest.java Fri Oct 31 16:49:23 2008
@@ -21,6 +21,7 @@
 import java.io.File;
 import java.net.URI;
 import java.util.Collection;
+import java.util.EnumSet;
 import java.util.List;
 
 import javax.xml.namespace.QName;
@@ -28,6 +29,7 @@
 import junit.framework.TestCase;
 
 import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
 
 public class ProcessStoreTest extends TestCase {
 
@@ -78,5 +80,28 @@
         assertEquals(pname,pconfs.get(0));
     }
     
-    
+    public void testCleanupConfigurations() {
+        Collection<QName> deployed = _ps.deploy(_testdd);
+        QName pname = deployed.iterator().next();
+        assertNotNull(deployed);
+        assertEquals(1,deployed.size());
+        ProcessConf pconf = _ps.getProcessConfiguration(pname);
+        assertNotNull(pconf);
+        assertEquals(_testdd.getName(),pconf.getPackage());
+        assertEquals(pname, pconf.getProcessId());
+        
+        assertEquals(EnumSet.allOf(CLEANUP_CATEGORY.class), pconf.getCleanupCategories(true));
+        assertEquals(EnumSet.of(CLEANUP_CATEGORY.MESSAGES, CLEANUP_CATEGORY.EVENTS), pconf.getCleanupCategories(false));
+        
+        assertTrue(pconf.isCleanupCategoryEnabled(true, CLEANUP_CATEGORY.INSTANCE));
+        assertTrue(pconf.isCleanupCategoryEnabled(true, CLEANUP_CATEGORY.VARIABLES));
+        assertTrue(pconf.isCleanupCategoryEnabled(true, CLEANUP_CATEGORY.MESSAGES));
+        assertTrue(pconf.isCleanupCategoryEnabled(true, CLEANUP_CATEGORY.CORRELATIONS));
+        assertTrue(pconf.isCleanupCategoryEnabled(true, CLEANUP_CATEGORY.EVENTS));
+        assertFalse(pconf.isCleanupCategoryEnabled(false, CLEANUP_CATEGORY.INSTANCE));
+        assertFalse(pconf.isCleanupCategoryEnabled(false, CLEANUP_CATEGORY.VARIABLES));
+        assertTrue(pconf.isCleanupCategoryEnabled(false, CLEANUP_CATEGORY.MESSAGES));
+        assertFalse(pconf.isCleanupCategoryEnabled(false, CLEANUP_CATEGORY.CORRELATIONS));
+        assertTrue(pconf.isCleanupCategoryEnabled(false, CLEANUP_CATEGORY.EVENTS));
+    } 
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-store/src/test/resources/testdd/deploy.xml
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-store/src/test/resources/testdd/deploy.xml?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-store/src/test/resources/testdd/deploy.xml (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-store/src/test/resources/testdd/deploy.xml Fri Oct 31 16:49:23 2008
@@ -26,5 +26,12 @@
 		<provide partnerLink="helloPartnerLink">
 			<service name="wns:HelloService" port="HelloPort"/>
 		</provide>
+		<cleanup on="success">
+			<category>all</category>
+		</cleanup>
+		<cleanup on="failure">
+			<category>messages</category>
+			<category>events</category>
+		</cleanup>
 	</process>
 </deploy>

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/mvn-hibernate.xml
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/mvn-hibernate.xml?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/mvn-hibernate.xml (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/mvn-hibernate.xml Fri Oct 31 16:49:23 2008
@@ -54,7 +54,7 @@
 
     <target name="export">
         <schemaexport properties="${src.databases}/${db}.properties" quiet="yes" text="yes" delimiter=";" output="${build.ddl}/${db}.sql">
-            <fileset dir="${build.classes}"><include name="**/*.hbm.xml"/></fileset>
+            <fileset dir="${build.classes}"><include name="**/*.hbm.xml"/><exclude name="**/HMessageExchangeProperty.hbm.xml"/></fileset>
         </schemaexport>
     </target>
-</project>
\ No newline at end of file
+</project>

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java Fri Oct 31 16:49:23 2008
@@ -83,7 +83,7 @@
    * @return
    * @throws MappingException
    */
-  public static final Configuration getDefaultConfiguration() throws MappingException {
+  public Configuration getDefaultConfiguration() throws MappingException {
     return new Configuration()
             .addClass(HProcess.class)
             .addClass(HProcessInstance.class)
@@ -100,8 +100,9 @@
             .addClass(HVariableProperty.class)
             .addClass(HBpelEvent.class)
 	        .addClass(HFaultData.class)
-	    .addClass(HActivityRecovery.class)
-            .addClass(HLargeData.class);
+	        .addClass(HActivityRecovery.class)
+            .addClass(HLargeData.class)
+            .addClass(HMessageExchangeProperty.class);
   }
 
   public static TransactionManager getTransactionManager(Properties props) {

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java Fri Oct 31 16:49:23 2008
@@ -33,8 +33,6 @@
  * Hibernate based {@link ActivityRecoveryDao} implementation
  */
 public class ActivityRecoveryDaoImpl extends HibernateDao implements ActivityRecoveryDAO {
-
-
     HActivityRecovery _self;
 
     public ActivityRecoveryDaoImpl(SessionManager sm, HActivityRecovery recovery) {
@@ -82,5 +80,4 @@
     public int getRetries() {
         return _self.getRetries();
     }
-
 }

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java Fri Oct 31 16:49:23 2008
@@ -45,7 +45,7 @@
 public class BpelDAOConnectionFactoryImpl implements BpelDAOConnectionFactoryJDBC {
     private static final Log __log = LogFactory.getLog(BpelDAOConnectionFactoryImpl.class);
 
-    private SessionManager _sessionManager;
+    protected SessionManager _sessionManager;
 
     private DataSource _ds;
 
@@ -69,6 +69,7 @@
     /**
      * @see org.apache.ode.bpel.dao.BpelDAOConnectionFactory#init(java.util.Properties)
      */
+    @SuppressWarnings("unchecked")
     public void init(Properties initialProps) {
         if (_ds == null) {
             String errmsg = "setDataSource() not called!";
@@ -131,8 +132,11 @@
                 __log.debug(name + "=" + properties.getProperty(name));
             }
         }
-        SessionManager sm = new SessionManager(properties, _ds, _tm);
-        _sessionManager = sm;
+        _sessionManager = createSessionManager(properties, _ds, _tm);
+    }
+    
+    protected SessionManager createSessionManager(Properties properties, DataSource ds, TransactionManager tm) {
+    	return new SessionManager(properties, ds, tm);
     }
 
     private static final String DEFAULT_HIBERNATE_DIALECT = "org.hibernate.dialect.DerbyDialect";

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java Fri Oct 31 16:49:23 2008
@@ -51,15 +51,15 @@
 /**
  * Hibernate-based {@link BpelDAOConnection} implementation.
  */
-class BpelDAOConnectionImpl implements BpelDAOConnection {
+public class BpelDAOConnectionImpl implements BpelDAOConnection {
 
     private static final Log __log = LogFactory.getLog(BpelDAOConnectionImpl.class);
 
     private Session _session;
 
-    private SessionManager _sm;
+    protected SessionManager _sm;
 
-    BpelDAOConnectionImpl(SessionManager sm) {
+    public BpelDAOConnectionImpl(SessionManager sm) {
         _sm = sm;
         _session = _sm.getSession();
     }
@@ -87,7 +87,7 @@
         _session.save(process);
         return new ProcessDaoImpl(_sm, process);
     }
-
+    
     public ProcessDAO getProcess(QName processId) {
 
         try {
@@ -131,7 +131,6 @@
         return daos;
     }
 
-    
     @SuppressWarnings("unchecked")
     static Iterator<HProcessInstance> _instanceQuery(Session session, boolean countOnly, InstanceFilter filter) {
         Criteria crit = session.createCriteria(HProcessInstance.class);

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageDaoImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageDaoImpl.java Fri Oct 31 16:49:23 2008
@@ -37,7 +37,7 @@
     private HMessage _hself;
     private Session _session;
 
-    protected MessageDaoImpl(SessionManager sessionManager, HMessage hobj) {
+    public MessageDaoImpl(SessionManager sessionManager, HMessage hobj) {
         super(sessionManager, hobj);
         entering("MessageDaoImpl.MessageDaoImpl");
         _hself = hobj;

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageExchangeDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageExchangeDaoImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageExchangeDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageExchangeDaoImpl.java Fri Oct 31 16:49:23 2008
@@ -19,12 +19,15 @@
 
 package org.apache.ode.daohib.bpel;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.dao.MessageDAO;
 import org.apache.ode.bpel.dao.MessageExchangeDAO;
 import org.apache.ode.bpel.dao.PartnerLinkDAO;
 import org.apache.ode.bpel.dao.ProcessDAO;
 import org.apache.ode.bpel.dao.ProcessInstanceDAO;
 import org.apache.ode.daohib.SessionManager;
+import org.apache.ode.daohib.bpel.hobj.HCorrelatorMessage;
 import org.apache.ode.daohib.bpel.hobj.HLargeData;
 import org.apache.ode.daohib.bpel.hobj.HMessage;
 import org.apache.ode.daohib.bpel.hobj.HMessageExchange;
@@ -38,9 +41,12 @@
 import java.util.Date;
 import java.util.Set;
 
-public class MessageExchangeDaoImpl extends HibernateDao implements MessageExchangeDAO {
-
-    private HMessageExchange _hself;
+public class MessageExchangeDaoImpl extends HibernateDao implements
+		MessageExchangeDAO {
+	@SuppressWarnings("unused")
+	private static final Log __log = LogFactory.getLog(MessageExchangeDaoImpl.class);
+	
+	private HMessageExchange _hself;
 
     // Used when provided process and instance aren't hibernate implementations. The relation
     // therefore can't be persisted. Used for in-mem DAOs so that doesn't matter much. 
@@ -337,7 +343,6 @@
         _hself.setPipedMessageExchangeId(mexId);
     }
 
-
 	public int getSubscriberCount() {
 		return _hself.getSubscriberCount();
 	}
@@ -345,12 +350,22 @@
 	public void setSubscriberCount(int subscriberCount) {
 		_hself.setSubscriberCount(subscriberCount);		
 	}
+	
+	public void release(boolean doClean) {
+		if( doClean ) {
+			deleteMessages();
+		}
+	}
 
 	public void incrementSubscriberCount() {
 		_hself.incrementSubscriberCount();
 	}
 	
-    public void release() {
-        // no-op for now, could be used to do some cleanup
-    }
-}
+	public void deleteMessages() {
+  		getSession().getNamedQuery(HLargeData.DELETE_MESSAGE_LDATA_BY_MEX).setParameter("mex", _hself).setParameter("mex2", _hself).executeUpdate();
+  		getSession().getNamedQuery(HCorrelatorMessage.DELETE_CORMESSAGES_BY_MEX).setParameter("mex", _hself).executeUpdate();
+  		
+		getSession().delete(_hself);
+		// This deletes endpoint LData, callbackEndpoint LData, request HMessage, response HMessage, HMessageExchangeProperty 
+	}
+}
\ No newline at end of file

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java Fri Oct 31 16:49:23 2008
@@ -18,15 +18,31 @@
  */
 package org.apache.ode.daohib.bpel;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.CorrelationKey;
 import org.apache.ode.bpel.dao.CorrelatorDAO;
 import org.apache.ode.bpel.dao.ProcessDAO;
 import org.apache.ode.bpel.dao.ProcessInstanceDAO;
 import org.apache.ode.daohib.SessionManager;
+import org.apache.ode.daohib.bpel.hobj.HActivityRecovery;
+import org.apache.ode.daohib.bpel.hobj.HBpelEvent;
+import org.apache.ode.daohib.bpel.hobj.HCorrelationProperty;
 import org.apache.ode.daohib.bpel.hobj.HCorrelationSet;
 import org.apache.ode.daohib.bpel.hobj.HCorrelator;
+import org.apache.ode.daohib.bpel.hobj.HCorrelatorMessage;
+import org.apache.ode.daohib.bpel.hobj.HCorrelatorMessageKey;
+import org.apache.ode.daohib.bpel.hobj.HFaultData;
+import org.apache.ode.daohib.bpel.hobj.HLargeData;
+import org.apache.ode.daohib.bpel.hobj.HMessage;
+import org.apache.ode.daohib.bpel.hobj.HMessageExchange;
+import org.apache.ode.daohib.bpel.hobj.HMessageExchangeProperty;
+import org.apache.ode.daohib.bpel.hobj.HPartnerLink;
 import org.apache.ode.daohib.bpel.hobj.HProcess;
 import org.apache.ode.daohib.bpel.hobj.HProcessInstance;
+import org.apache.ode.daohib.bpel.hobj.HScope;
+import org.apache.ode.daohib.bpel.hobj.HVariableProperty;
+import org.apache.ode.daohib.bpel.hobj.HXmlData;
 import org.hibernate.Criteria;
 import org.hibernate.Hibernate;
 import org.hibernate.Query;
@@ -41,9 +57,11 @@
 /**
  * Hibernate-based {@link ProcessDAO} implementation.
  */
-class ProcessDaoImpl extends HibernateDao implements ProcessDAO {
-
-    private static final String QRY_CORRELATOR = "where this.correlatorId = ?";
+public class ProcessDaoImpl extends HibernateDao implements ProcessDAO {
+	@SuppressWarnings("unused")
+	private static final Log __log = LogFactory.getLog(ProcessDaoImpl.class);
+	
+	private static final String QRY_CORRELATOR = "where this.correlatorId = ?";
 
     private HProcess _process;
 
@@ -114,7 +132,6 @@
         criteria.add(Expression.eq("value", ckeyValue.toCanonicalString()));
         criteria.addOrder(Order.desc("scope.instance.created"));
         return criteria.list();
-
     }
 
     /**
@@ -126,10 +143,60 @@
 
     public void delete() {
         entering("ProcessDaoImpl.delete");
-        getSession().delete(_process);
+
+        deleteEvents();
+        deleteCorrelations();
+		deleteMessages();
+		deleteVariables();
+		deleteProcessInstances();
+
+		getSession().delete(_process); // this deletes HCorrelator -> HCorrelatorSelector
     }
 
-    public QName getType() {
+    private void deleteProcessInstances() {
+  		getSession().getNamedQuery(HLargeData.DELETE_ACTIVITY_RECOVERY_LDATA_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HActivityRecovery.DELETE_ACTIVITY_RECOVERIES_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HLargeData.DELETE_FAULT_LDATA_BY_PROCESS).setParameter("process", _process).executeUpdate();
+        getSession().getNamedQuery(HFaultData.DELETE_FAULTS_BY_PROCESS).setParameter("process", _process).executeUpdate();
+        getSession().getNamedQuery(HLargeData.DELETE_JACOB_LDATA_BY_PROCESS).setParameter("process", _process).executeUpdate();
+        getSession().getNamedQuery(HProcessInstance.DELETE_INSTANCES_BY_PROCESS).setParameter("process", _process).executeUpdate();
+    }
+
+    private void deleteVariables() {
+  		getSession().getNamedQuery(HCorrelationProperty.DELETE_CORPROPS_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HCorrelationSet.DELETE_CORSETS_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+
+  		getSession().getNamedQuery(HVariableProperty.DELETE_VARIABLE_PROPERITES_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HLargeData.DELETE_XMLDATA_LDATA_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HXmlData.DELETE_XMLDATA_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+
+  		getSession().getNamedQuery(HLargeData.DELETE_PARTNER_LINK_LDATA_BY_PROCESS).setParameter ("process", _process).setParameter ("process2", _process).executeUpdate();
+  		getSession().getNamedQuery(HPartnerLink.DELETE_PARTNER_LINKS_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HScope.DELETE_SCOPES_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+    }
+
+    private void deleteMessages() {
+  		getSession().getNamedQuery(HCorrelatorMessage.DELETE_CORMESSAGES_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+
+  		getSession().getNamedQuery(HLargeData.DELETE_MESSAGE_LDATA_BY_PROCESS).setParameter("process", _process).setParameter ("process2", _process).executeUpdate();
+  		getSession().getNamedQuery(HMessage.DELETE_MESSAGES_BY_PROCESS).setParameter("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HMessageExchangeProperty.DELETE_MEX_PROPS_BY_PROCESS).setParameter("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HLargeData.DELETE_MEX_LDATA_BY_PROCESS).setParameter("process", _process).setParameter("process2", _process).executeUpdate();
+  		getSession().getNamedQuery(HMessageExchange.DELETE_MEX_BY_PROCESS).setParameter("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HCorrelator.DELETE_CORRELATORS_BY_PROCESS).setParameter("process", _process).executeUpdate();
+    }
+
+    private void deleteCorrelations() {
+  		getSession().getNamedQuery(HCorrelationProperty.DELETE_CORPROPS_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HCorrelationSet.DELETE_CORSETS_BY_PROCESS).setParameter ("process", _process).executeUpdate();
+    }
+
+    private void deleteEvents() {
+  		getSession().getNamedQuery(HLargeData.DELETE_EVENT_LDATA_BY_PROCESS).setParameter("process", _process).executeUpdate();
+  		getSession().getNamedQuery(HBpelEvent.DELETE_EVENTS_BY_PROCESS).setParameter("process", _process).executeUpdate();
+  	}
+
+  	public QName getType() {
         return new QName(_process.getTypeNamespace(), _process.getTypeName());
     }
 
@@ -159,5 +226,4 @@
     public String getGuid() {
         return _process.getGuid();
     }
-
 }

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java Fri Oct 31 16:49:23 2008
@@ -18,9 +18,12 @@
  */
 package org.apache.ode.daohib.bpel;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.ProcessState;
 import org.apache.ode.bpel.dao.*;
 import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
 import org.apache.ode.daohib.SessionManager;
 import org.apache.ode.daohib.bpel.hobj.*;
 import org.apache.ode.utils.DOMUtils;
@@ -40,7 +43,9 @@
 /**
  * Hibernate-based {@link ProcessInstanceDAO} implementation.
  */
-class ProcessInstanceDaoImpl extends HibernateDao implements ProcessInstanceDAO {
+public class ProcessInstanceDaoImpl extends HibernateDao implements ProcessInstanceDAO {
+	private static final Log __log = LogFactory.getLog(ProcessInstanceDaoImpl.class);
+
   /** Query for removing selectors. */
   private static final String QRY_DELSELECTORS = "delete from "  + 
     HCorrelatorSelector.class.getName() + " where instance = ?";
@@ -285,6 +290,7 @@
      * TODO this is never used, except by test cases - should be removed
      * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getVariables(java.lang.String, int)
      */
+    @SuppressWarnings("unchecked")
 	public XmlDataDAO[] getVariables(String variableName, int scopeModelId) {
         entering("ProcessInstanceDaoImpl.getVariables");
     List<XmlDataDAO> results = new ArrayList<XmlDataDAO>();
@@ -315,21 +321,82 @@
     this.getProcess().instanceCompleted(this);
   }
 
-  public void delete() {
+  public void delete(Set<CLEANUP_CATEGORY> cleanupCategories) {
       entering("ProcessInstanceDaoImpl.delete");
-    _sm.getSession().delete(_instance);
+	  if(__log.isDebugEnabled()) __log.debug("Cleaning up instance data with categories = " + cleanupCategories);
+      
+	  getSession().delete(_instance.getJacobState());
+	  
+      if( cleanupCategories.contains(CLEANUP_CATEGORY.EVENTS) ) {
+    	  deleteEvents();
+      }
+      
+      if( cleanupCategories.contains(CLEANUP_CATEGORY.CORRELATIONS) ) {
+    	  deleteCorrelations();
+      }
+      
+      if( cleanupCategories.contains(CLEANUP_CATEGORY.MESSAGES) ) {
+    	  deleteMessages();
+      }
+      
+      if( cleanupCategories.contains(CLEANUP_CATEGORY.VARIABLES) ) {
+    	  deleteVariables();
+      }
+      
+      if( cleanupCategories.contains(CLEANUP_CATEGORY.INSTANCE) ) {
+    	  deleteInstance();
+      }
+
+      getSession().flush();
+      
+	  if(__log.isDebugEnabled()) __log.debug("Instance data cleaned up and flushed.");
   }
+  
+  	private void deleteInstance() {
+  		getSession().getNamedQuery(HLargeData.DELETE_FAULT_LDATA_BY_INSTANCE_ID).setParameter ("instanceId", _instance.getId()).executeUpdate();
+		getSession().getNamedQuery(HFaultData.DELETE_FAULTS_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+
+		getSession().delete(_instance); // this deletes JcobState, HActivityRecovery -> ActivityRecovery-LData
+  	}
+  	
+  	private void deleteVariables() {
+		getSession().getNamedQuery(HCorrelationProperty.DELETE_CORPROPS_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+		getSession().getNamedQuery(HCorrelationSet.DELETE_CORSETS_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+
+  		getSession().getNamedQuery(HVariableProperty.DELETE_VARIABLE_PROPERITES_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+		getSession().getNamedQuery(HLargeData.DELETE_XMLDATA_LDATA_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+		getSession().getNamedQuery(HXmlData.DELETE_XMLDATA_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+
+		getSession().getNamedQuery(HLargeData.DELETE_PARTNER_LINK_LDATA_BY_INSTANCE).setParameter ("instance", _instance).setParameter ("instance2", _instance).executeUpdate();
+		getSession().getNamedQuery(HPartnerLink.DELETE_PARTNER_LINKS_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+
+		getSession().getNamedQuery(HScope.DELETE_SCOPES_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+  	}
+
+    private void deleteMessages() {
+  		getSession().getNamedQuery(HCorrelatorSelector.DELETE_MESSAGE_ROUTES_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+  	}
+  
+  	private void deleteCorrelations() {
+		getSession().getNamedQuery(HCorrelationProperty.DELETE_CORPROPS_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+		getSession().getNamedQuery(HCorrelationSet.DELETE_CORSETS_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+  	}
+
+  	private void deleteEvents() {
+		getSession().getNamedQuery(HLargeData.DELETE_EVENT_LDATA_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();
+		getSession().getNamedQuery(HBpelEvent.DELETE_EVENTS_BY_INSTANCE).setParameter ("instance", _instance).executeUpdate();		
+	}
 
   public void insertBpelEvent(ProcessInstanceEvent event) {
       entering("ProcessInstanceDaoImpl.insertBpelEvent");
     // Defer to the BpelDAOConnectionImpl
-    BpelDAOConnectionImpl._insertBpelEvent(_sm.getSession(),event, this.getProcess(), this);
+    BpelDAOConnectionImpl._insertBpelEvent(getSession(), event, this.getProcess(), this);
   }
 
   public EventsFirstLastCountTuple getEventsFirstLastCount() {
       entering("ProcessInstanceDaoImpl.getEventsFirstLastCount");
     // Using a criteria, find the min,max, and count of event tstamps.
-    Criteria c = _sm.getSession().createCriteria(HBpelEvent.class);
+    Criteria c = getSession().createCriteria(HBpelEvent.class);
     c.add(Restrictions.eq("instance",_instance));
     c.setProjection(Projections.projectionList().add(Projections.min("tstamp"))
                                                 .add(Projections.max("tstamp"))
@@ -343,6 +410,16 @@
     return flc;
   }
 
+  public Collection<MessageExchangeDAO> getMessageExchanges() {
+	  Collection<MessageExchangeDAO> exchanges = new ArrayList<MessageExchangeDAO>();
+	  
+	  for( HMessageExchange exchange : _instance.getMessageExchanges() ) {
+		  exchanges.add(new MessageExchangeDaoImpl(_sm, exchange));
+	  }
+	  
+	  return exchanges;
+  }
+  
   public long genMonotonic() {
       entering("ProcessInstanceDaoImpl.genMonotonic");
     long seq = _instance.getSequence()+1;
@@ -365,6 +442,7 @@
     return _instance.getActivityFailureDateTime();
   }
 
+  @SuppressWarnings("unchecked")
   public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
       entering("ProcessInstanceDaoImpl.getActivityRecoveries");
     List<ActivityRecoveryDAO> results = new ArrayList<ActivityRecoveryDAO>();

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java Fri Oct 31 16:49:23 2008
@@ -24,8 +24,10 @@
 /**
  * Persistent representation of activity recovery information.
  * @hibernate.class table="BPEL_ACTIVITY_RECOVERY"
+ * @hibernate.query name="DELETE_ACTIVITY_RECOVERIES_BY_PROCESS" query="delete from HActivityRecovery as a where a.instance in(select i from HProcessInstance as i where i.process = :process)"
  */
 public class HActivityRecovery extends HObject {
+	public final static String DELETE_ACTIVITY_RECOVERIES_BY_PROCESS = "DELETE_ACTIVITY_RECOVERIES_BY_PROCESS";
 
   /** Process instance to which this scope belongs. */
   private HProcessInstance _instance;
@@ -40,7 +42,7 @@
   /**
    * Get the {@link HProcessInstance} to which this scope object belongs.
    * @hibernate.many-to-one
-   *  column="PIID"
+   *  column="PIID" foreign-key="none"
    */
 	public HProcessInstance getInstance() {
 		return _instance;
@@ -96,7 +98,7 @@
 	}
 
   /**
-   * @hibernate.many-to-one column="LDATA_ID" cascade="delete"
+   * @hibernate.many-to-one column="LDATA_ID" cascade="delete" foreign-key="none"
    */
   public HLargeData getDetails() {
     return _details;

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HBpelEvent.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HBpelEvent.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HBpelEvent.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HBpelEvent.java Fri Oct 31 16:49:23 2008
@@ -27,8 +27,13 @@
  * Row representation of a BPEL event. 
  *
  * @hibernate.class table="BPEL_EVENT"
+ * @hibernate.query name="DELETE_EVENTS_BY_PROCESS" query="delete from HBpelEvent as e where e.process = :process"
+ * @hibernate.query name="DELETE_EVENTS_BY_INSTANCE" query="delete from HBpelEvent as e where e.instance = :instance"
  */
 public class HBpelEvent extends HObject {
+	public final static String DELETE_EVENTS_BY_PROCESS = "DELETE_EVENTS_BY_PROCESS";
+	public static final String DELETE_EVENTS_BY_INSTANCE = "DELETE_EVENTS_BY_INSTANCE";
+	
   private Timestamp _tstamp;
   private String _type;
   private String _detail;
@@ -41,8 +46,7 @@
   private Long _scopeId;
 
   /**
-   * @hibernate.many-to-one
-   *  column="IID"
+   * @hibernate.many-to-one column="IID" foreign-key="none"
    */
   public HProcessInstance getInstance() {
     return _instance;
@@ -53,8 +57,7 @@
   }
 
   /**
-   * @hibernate.many-to-one
-   *  column="PID"
+   * @hibernate.many-to-one column="PID" foreign-key="none"
    */
   public HProcess getProcess() {
     return _process;
@@ -107,7 +110,7 @@
 
 
   /**
-   * @hibernate.many-to-one column="LDATA_ID" cascade="delete"
+   * @hibernate.many-to-one column="LDATA_ID" cascade="delete" foreign-key="none"
    */
   public HLargeData getData() {
     return _data;

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationProperty.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationProperty.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationProperty.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationProperty.java Fri Oct 31 16:49:23 2008
@@ -26,8 +26,13 @@
  * Hibernate table-mapped class representing one valued property in
  * a correlation set.
  * @hibernate.class table="BPEL_CORRELATION_PROP"
+ * @hibernate.query name="DELETE_CORPROPS_BY_PROCESS" query="delete from HCorrelationProperty as p where p.correlationSet in(select s from HCorrelationSet as s where s.process = :process)"
+ * @hibernate.query name="DELETE_CORPROPS_BY_INSTANCE" query="delete from HCorrelationProperty as p where p.correlationSet in(select s from HCorrelationSet as s where s.instance = :instance)"
  */
 public class HCorrelationProperty extends HObject {
+	public final static String DELETE_CORPROPS_BY_PROCESS = "DELETE_CORPROPS_BY_PROCESS";
+	public final static String DELETE_CORPROPS_BY_INSTANCE = "DELETE_CORPROPS_BY_INSTANCE";
+	
   private String _name;
   private String _namespace;
   private String _value;
@@ -87,7 +92,7 @@
   }
 
   /**
-   * @hibernate.many-to-one column="CORR_SET_ID"
+   * @hibernate.many-to-one column="CORR_SET_ID" foreign-key="none"
    */
   public HCorrelationSet getCorrelationSet() {
     return _correlationSet;

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java Fri Oct 31 16:49:23 2008
@@ -25,8 +25,13 @@
 /**
  * Hibernate table representing correlation set values.
  * @hibernate.class table="BPEL_CORRELATION_SET"
+ * @hibernate.query name="DELETE_CORSETS_BY_INSTANCE" query="delete from HCorrelationSet as c where c.instance = :instance"
+ * @hibernate.query name="DELETE_CORSETS_BY_PROCESS" query="delete from HCorrelationSet as c where c.process = :process"
  */
 public class HCorrelationSet extends HObject{
+  public static final String DELETE_CORSETS_BY_INSTANCE = "DELETE_CORSETS_BY_INSTANCE";
+  public static final String DELETE_CORSETS_BY_PROCESS = "DELETE_CORSETS_BY_PROCESS";
+
   private HProcess _process;
   private HProcessInstance _instance;
   private Collection<HCorrelationProperty> _properties = new HashSet<HCorrelationProperty>();
@@ -77,7 +82,7 @@
 
   /**
    * @hibernate.many-to-one
-   *  column="SCOPE_ID"
+   *  column="SCOPE_ID" foreign-key="none"
    */
 	public HScope getScope() {
 		return _scope;
@@ -85,7 +90,7 @@
 
   /**
    * @hibernate.many-to-one
-   *  column="PIID"
+   *  column="PIID" foreign-key="none"
    */
   public HProcessInstance getInstance() {
     return _instance;
@@ -97,7 +102,7 @@
 
   /**
    * @hibernate.many-to-one
-   *  column="PROCESS_ID"
+   *  column="PROCESS_ID" foreign-key="none"
    */
   public HProcess getProcess() {
     return _process;
@@ -113,7 +118,7 @@
    *  inverse="true"
    *  cascade="delete"
    * @hibernate.collection-key
-   *  column="CORR_SET_ID"
+   *  column="CORR_SET_ID" foreign-key="none"
    * @hibernate.collection-one-to-many
    *  class="org.apache.ode.daohib.bpel.hobj.HCorrelationProperty"
    */

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelator.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelator.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelator.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelator.java Fri Oct 31 16:49:23 2008
@@ -31,9 +31,11 @@
  * matched up to a pcik/receive.
  * 
  * @hibernate.class table="BPEL_CORRELATOR"
+ * @hibernate.query name="DELETE_CORRELATORS_BY_PROCESS" query="delete from HCorrelator as c where c.process = :process"
  */
 public class HCorrelator extends HObject {
-
+	public final static String DELETE_CORRELATORS_BY_PROCESS = "DELETE_CORRELATORS_BY_PROCESS";
+	
     private HProcess _process;
 
     private String _correlatorId;
@@ -53,8 +55,8 @@
      * Get the set of {@link HCorrelatorMessage} objects representing the
      * messages that need matching to a selector (i.e. pick/receive).
      * 
-     * @hibernate.set lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="CORRELATOR"
+     * @hibernate.set lazy="true" inverse="true"
+     * @hibernate.collection-key column="CORRELATOR" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HCorrelatorMessage"
      */
     public Set<HCorrelatorMessage> getMessageCorrelations() {
@@ -80,7 +82,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="PROCESS_ID"
+     * @hibernate.many-to-one column="PROCESS_ID" foreign-key="none"
      */
     public HProcess getProcess() {
         return _process;
@@ -95,8 +97,8 @@
      * Get the set of {@link HCorrelatorSelector} objects representing the
      * selectors (i.e. pick/receive) that need matching to an input message.
      * 
-     * @hibernate.set lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="CORRELATOR"
+     * @hibernate.set lazy="true" inverse="true"
+     * @hibernate.collection-key column="CORRELATOR" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HCorrelatorSelector"
      */
     public Set<HCorrelatorSelector> getSelectors() {

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorMessage.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorMessage.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorMessage.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorMessage.java Fri Oct 31 16:49:23 2008
@@ -21,15 +21,19 @@
 
 /**
  * @hibernate.class table="BPEL_UNMATCHED" lazy="true"
+ * @hibernate.query name="DELETE_CORMESSAGES_BY_PROCESS" query="delete from HCorrelatorMessage as m where m.correlator in(select c from HCorrelator as c where c.process = :process)"
+ * @hibernate.query name="DELETE_CORMESSAGES_BY_MEX" query="delete from HCorrelatorMessage as m where m.messageExchange = :mex"
  */
 public class HCorrelatorMessage extends HObject {
-
+	public final static String DELETE_CORMESSAGES_BY_PROCESS = "DELETE_CORMESSAGES_BY_PROCESS";
+	public final static String DELETE_CORMESSAGES_BY_MEX = "DELETE_CORMESSAGES_BY_MEX";
+	
     private HMessageExchange _messageExchange;
     private HCorrelator _correlator;
     private String _correlationKey;
 
     /**
-     * @hibernate.many-to-one column="MEX"
+     * @hibernate.many-to-one column="MEX" foreign-key="none"
      */
     public HMessageExchange getMessageExchange() {
         return _messageExchange;
@@ -60,7 +64,7 @@
     }
 
     /**
-     * @hibernate.many-to-one
+     * @hibernate.many-to-one foreign-key="none"
      * @hibernate.column name="CORRELATOR" index="IDX_UNMATCHED_CORRELATOR" not-null="true"
      */
     public HCorrelator getCorrelator() {

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorMessageKey.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorMessageKey.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorMessageKey.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorMessageKey.java Fri Oct 31 16:49:23 2008
@@ -24,11 +24,9 @@
  * targetted at the BPEL process with no matching instance at the time of
  * receipt (and createInstance is not possible).
  *
- * @hibernate.class
- *   table="BPEL_CORRELATOR_MESSAGE_CKEY"
+ * @hibernate.class table="BPEL_CORRELATOR_MESSAGE_CKEY"
  */
 public class HCorrelatorMessageKey extends HObject {
-
   /** Correlation Key canonical string representation. */
   private String _keyCanonical;
 
@@ -61,7 +59,7 @@
   /**
    * The message with which this correlation key value is associated.
    * @hibernate.many-to-one
-   *   column="CORRELATOR_MESSAGE_ID"
+   *   column="CORRELATOR_MESSAGE_ID" foreign-key="none"
    */
   public HCorrelatorMessage getOwner() {
     return _owner;

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorSelector.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorSelector.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorSelector.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelatorSelector.java Fri Oct 31 16:49:23 2008
@@ -21,10 +21,11 @@
 
 /**
  * @hibernate.class table="BPEL_SELECTORS" lazy="true"
- * 
+ * @hibernate.query name="DELETE_MESSAGE_ROUTES_BY_INSTANCE" query="delete from HCorrelatorSelector as m where m.instance = :instance)"
  */
 public class HCorrelatorSelector extends HObject {
-
+	public static final String DELETE_MESSAGE_ROUTES_BY_INSTANCE = "DELETE_MESSAGE_ROUTES_BY_INSTANCE";
+	
     private HProcessInstance _instance;
     private String _groupId;
     private int _idx;
@@ -34,7 +35,7 @@
     private String _routePolicy;
     
     /**
-     * @hibernate.many-to-one column="PIID" not-null="true"
+     * @hibernate.many-to-one column="PIID" not-null="true" foreign-key="none"
      */
     public HProcessInstance getInstance() {
         return _instance;
@@ -113,7 +114,7 @@
     }
 
     /**
-     * @hibernate.many-to-one not-null="true"
+     * @hibernate.many-to-one not-null="true" foreign-key="none"
      * @hibernate.column name="CORRELATOR" not-null="true" 
      *          index="IDX_SELECTOR_CORRELATOR" unique-key="UNIQ_SELECTOR"
      */

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HFaultData.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HFaultData.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HFaultData.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HFaultData.java Fri Oct 31 16:49:23 2008
@@ -23,8 +23,12 @@
 /**
  * Persistent representation of a fault.
  * @hibernate.class table="BPEL_FAULT"
+ * @hibernate.query name="DELETE_FAULTS_BY_PROCESS" query="delete from HFaultData as f where f in (select i.fault from HProcessInstance as i where i.process = :process)"
+ * @hibernate.query name="DELETE_FAULTS_BY_INSTANCE" query="delete from HFaultData as f where f in (select i.fault from HProcessInstance as i where i = :instance)"
  */
 public class HFaultData extends HObject {
+  public final static String DELETE_FAULTS_BY_PROCESS = "DELETE_FAULTS_BY_PROCESS";
+  public final static String DELETE_FAULTS_BY_INSTANCE = "DELETE_FAULTS_BY_INSTANCE";
 
   private String _name;
   private String _explanation;
@@ -44,7 +48,7 @@
 	}
 
   /**
-   * @hibernate.many-to-one column="LDATA_ID" cascade="delete"
+   * @hibernate.many-to-one column="LDATA_ID" cascade="delete" foreign-key="none"
    */
   public HLargeData getData() {
     return _data;

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HLargeData.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HLargeData.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HLargeData.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HLargeData.java Fri Oct 31 16:49:23 2008
@@ -24,9 +24,37 @@
  * instance needs to store as part of its state large binary or text
  * data, a reference to an instance of this class must be created.
  * @hibernate.class table="LARGE_DATA"
+ * @hibernate.query name="DELETE_EVENT_LDATA_BY_PROCESS" query="delete from HLargeData as d where d in(select e.data from HBpelEvent as e where e.process = :process)"
+ * @hibernate.query name="DELETE_XMLDATA_LDATA_BY_PROCESS" query="delete from HLargeData as d where d in(select x.data from HXmlData as x where x.instance.process = :process)"
+ * @hibernate.query name="DELETE_ACTIVITY_RECOVERY_LDATA_BY_PROCESS" query="delete from HLargeData as d where d in(select a.details from HActivityRecovery as a where a.instance.process = :process)"
+ * @hibernate.query name="DELETE_FAULT_LDATA_BY_PROCESS" query="delete from HLargeData as d where d in(select f.data from HFaultData as f, HProcessInstance as i where f.id = i.fault and i.process = :process)"
+ * @hibernate.query name="DELETE_JACOB_LDATA_BY_PROCESS" query="delete from HLargeData as d where d in(select i.jacobState from HProcessInstance as i where i.process = :process)"
+ * @hibernate.query name="DELETE_PARTNER_LINK_LDATA_BY_PROCESS" query="delete from HLargeData as d where d in(select l.myEPR from HPartnerLink as l where l.scope.instance.process = :process) or d IN(select l.partnerEPR from HPartnerLink as l where l.scope.instance.process = :process2)"
+ * @hibernate.query name="DELETE_MESSAGE_LDATA_BY_PROCESS" query="delete from HLargeData as d where d in(select m.messageData from HMessage m where m.messageExchange.process = :process) or d IN(select m.header from HMessage m where m.messageExchange.process = :process2)"
+ * @hibernate.query name="DELETE_MEX_LDATA_BY_PROCESS" query="delete from HLargeData as d where d in(select e.endpoint from HMessageExchange as e where e.process = :process) or d IN(select e.callbackEndpoint from HMessageExchange as e where e.process = :process2)"
+ * 
+ * @hibernate.query name="DELETE_EVENT_LDATA_BY_INSTANCE" query="delete from HLargeData as d where d in(select e.data from HBpelEvent as e where e.instance = :instance)"
+ * @hibernate.query name="DELETE_MESSAGE_LDATA_BY_MEX" query="delete from HLargeData as d where d in(select m.messageData from HMessage m where m.messageExchange = :mex) or d IN(select m.header from HMessage m where m.messageExchange = :mex2)"
+ * @hibernate.query name="DELETE_XMLDATA_LDATA_BY_INSTANCE" query="delete from HLargeData as d where d in(select x.data from HXmlData as x where x.instance = :instance)"
+ * @hibernate.query name="DELETE_PARTNER_LINK_LDATA_BY_INSTANCE" query="delete from HLargeData as d where d in(select l.myEPR from HPartnerLink as l where l.scope.instance = :instance) or d IN(select l.partnerEPR from HPartnerLink as l where l.scope.instance = :instance2)"
+ * @hibernate.query name="DELETE_FAULT_LDATA_BY_INSTANCE_ID" query="delete from HLargeData as d where d in(select f.data from HFaultData as f, HProcessInstance as i where f.id = i.fault and i.id = :instanceId)"
  */
 public class HLargeData extends HObject {
-
+	public final static String DELETE_EVENT_LDATA_BY_PROCESS = "DELETE_EVENT_LDATA_BY_PROCESS";
+	public final static String DELETE_XMLDATA_LDATA_BY_PROCESS = "DELETE_XMLDATA_LDATA_BY_PROCESS";
+	public final static String DELETE_ACTIVITY_RECOVERY_LDATA_BY_PROCESS = "DELETE_ACTIVITY_RECOVERY_LDATA_BY_PROCESS";
+	public final static String DELETE_FAULT_LDATA_BY_PROCESS = "DELETE_FAULT_LDATA_BY_PROCESS";
+	public final static String DELETE_JACOB_LDATA_BY_PROCESS = "DELETE_JACOB_LDATA_BY_PROCESS";
+	public final static String DELETE_PARTNER_LINK_LDATA_BY_PROCESS = "DELETE_PARTNER_LINK_LDATA_BY_PROCESS";
+	public final static String DELETE_MESSAGE_LDATA_BY_PROCESS = "DELETE_MESSAGE_LDATA_BY_PROCESS";
+	public final static String DELETE_MEX_LDATA_BY_PROCESS = "DELETE_MEX_LDATA_BY_PROCESS";
+
+	public final static String DELETE_EVENT_LDATA_BY_INSTANCE = "DELETE_EVENT_LDATA_BY_INSTANCE";
+	public final static String DELETE_MESSAGE_LDATA_BY_MEX = "DELETE_MESSAGE_LDATA_BY_MEX";
+	public final static String DELETE_XMLDATA_LDATA_BY_INSTANCE = "DELETE_XMLDATA_LDATA_BY_INSTANCE";
+	public final static String DELETE_PARTNER_LINK_LDATA_BY_INSTANCE = "DELETE_PARTNER_LINK_LDATA_BY_INSTANCE";
+	public final static String DELETE_FAULT_LDATA_BY_INSTANCE_ID = "DELETE_FAULT_LDATA_BY_INSTANCE_ID";
+	
   private byte[] binary = null;
 
   public HLargeData() {

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessage.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessage.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessage.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessage.java Fri Oct 31 16:49:23 2008
@@ -18,14 +18,16 @@
  */
 package org.apache.ode.daohib.bpel.hobj;
 
-
 /**
  * Hibernate-managed table for keeping track of messages.
  *
- * @hibernate.class
- *  table="BPEL_MESSAGE"
+ * @hibernate.class table="BPEL_MESSAGE"
+ * @hibernate.query name="DELETE_MESSAGES_BY_MEX" query="delete from HMessage as m WHERE m.messageExchange = :messageExchange"
+ * @hibernate.query name="DELETE_MESSAGES_BY_PROCESS" query="delete from HMessage as m WHERE m.messageExchange IN(select e from HMessageExchange e where e.process = :process)"
  */
 public class HMessage extends HObject {
+	public final static String DELETE_MESSAGES_BY_MEX = "DELETE_MESSAGES_BY_MEX";
+	public final static String DELETE_MESSAGES_BY_PROCESS = "DELETE_MESSAGES_BY_PROCESS";
 
   private HMessageExchange _mex;
   private String _type;
@@ -36,7 +38,7 @@
     _mex = mex;
   }
   
-  /** @hibernate.many-to-one column="MEX" */
+  /** @hibernate.many-to-one column="MEX" foreign-key="none"*/
   public HMessageExchange getMessageExchange() {
     return _mex;
   }
@@ -51,7 +53,7 @@
   }
 
   /**
-   * @hibernate.many-to-one column="DATA" lazy="false" outer-join="true" 
+   * @hibernate.many-to-one column="DATA" lazy="false" outer-join="true" foreign-key="none"
    * */
   public HLargeData getMessageData() {
     return _data;
@@ -61,7 +63,7 @@
     _data = data;
   }
 
-  /** @hibernate.many-to-one column="HEADER"  lazy="false" outer-join="true" */
+  /** @hibernate.many-to-one column="HEADER"  lazy="false" outer-join="true" foreign-key="none" */
   public HLargeData getHeader() {
     return _header;
   }

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessageExchange.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessageExchange.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessageExchange.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessageExchange.java Fri Oct 31 16:49:23 2008
@@ -27,8 +27,13 @@
  * Hibernate-managed table for keeping track of message exchanges.
  * 
  * @hibernate.class table="BPEL_MESSAGE_EXCHANGE" dynamic-update="true"
+ * @hibernate.query name="DELETE_MEX_BY_INSTANCE" query="delete from HMessageExchange as m where m.instance = :instance"
+ * @hibernate.query name="DELETE_MEX_BY_PROCESS" query="delete from HMessageExchange as m where m.process = :process"
+ * hibernate.query name="DELETE_MEX_PROPERTIES_BY_PROCESS" query="delete from HMessageExchange.properties as m where key(m).process = :process"
  */
 public class HMessageExchange extends HObject {
+	public final static String DELETE_MEX_BY_INSTANCE = "DELETE_MEX_BY_INSTANCE";
+	public final static String DELETE_MEX_BY_PROCESS = "DELETE_MEX_BY_PROCESS";
 
     private String _channelName;
 
@@ -117,7 +122,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="LDATA_EPR_ID" cascade="delete"
+     * @hibernate.many-to-one column="LDATA_EPR_ID" cascade="delete" foreign-key="none"
      */
     public HLargeData getEndpoint() {
         return _endpoint;
@@ -128,7 +133,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="LDATA_CEPR_ID" cascade="delete"
+     * @hibernate.many-to-one column="LDATA_CEPR_ID" cascade="delete" foreign-key="none"
      */
     public HLargeData getCallbackEndpoint() {
         return _callbackEndpoint;
@@ -139,7 +144,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="REQUEST" cascade="delete"
+     * @hibernate.many-to-one column="REQUEST" cascade="delete" foreign-key="none"
      */
     public HMessage getRequest() {
         return _request;
@@ -150,7 +155,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="RESPONSE" cascade="delete"
+     * @hibernate.many-to-one column="RESPONSE" cascade="delete" foreign-key="none"
      */
     public HMessage getResponse() {
         return _response;
@@ -194,7 +199,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="PROCESS"
+     * @hibernate.many-to-one column="PROCESS" foreign-key="none"
      */
     public HProcess getProcess() {
         return _process;
@@ -205,7 +210,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="PIID"
+     * @hibernate.many-to-one column="PIID" foreign-key="none"
      */
     public HProcessInstance getInstance() {
         return _instance;
@@ -303,7 +308,7 @@
     /**
      * @hibernate.map name="properties" table="BPEL_MEX_PROPS" lazy="true"
      *                cascade="delete"
-     * @hibernate.collection-key column="MEX"
+     * @hibernate.collection-key name="mex" column="MEX" foreign-key="none"
      * @hibernate.collection-index column="NAME" type="string"
      * @hibernate.collection-element column="VALUE" type="string" length="8000"
      */
@@ -320,7 +325,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="PARTNERLINK" 
+     * @hibernate.many-to-one column="PARTNERLINK" foreign-key="none"
      */
     public HPartnerLink getPartnerLink() {
         return _partnerLink;

Added: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessageExchangeProperty.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessageExchangeProperty.java?rev=709602&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessageExchangeProperty.java (added)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HMessageExchangeProperty.java Fri Oct 31 16:49:23 2008
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.daohib.bpel.hobj;
+
+import java.io.Serializable;
+
+/**
+ * This hibernate entity enables using the BPEL_MEX_PROPS table in HQL. This entity
+ * is excluded from schema export.
+ * 
+ * @hibernate.class table="BPEL_MEX_PROPS" lazy="true"
+ * @hibernate.query name="DELETE_MEX_PROPS_BY_PROCESS" query="delete from HMessageExchangeProperty as p where p.mex in(select e from HMessageExchange e where e.process = :process)"
+ */
+@SuppressWarnings("serial")
+public class HMessageExchangeProperty implements Serializable {
+	public final static String DELETE_MEX_PROPS_BY_PROCESS = "DELETE_MEX_PROPS_BY_PROCESS";
+
+	private HMessageExchange _mex;
+	private String _name;
+	private String _value;
+
+	public HMessageExchangeProperty() {
+	}
+
+	/**
+	 * @hibernate.id
+	 * @return
+	 */
+	public HMessageExchangeProperty getKey() {
+		return null;
+	}
+
+	public void setKey(HMessageExchangeProperty property) {
+	}
+	
+    /**
+     * @hibernate.many-to-one column="MEX" insert="false" update="false"
+     */
+	public HMessageExchange getMex() {
+		return _mex;
+	}
+
+	public void setMex(HMessageExchange mex) {
+		_mex = mex;
+	}
+
+	/**
+	 * @hibernate.property column="NAME" type="string" length="8000" insert="false" update="false"
+	 */
+	public String getName() {
+		return _name;
+	}
+	
+	public void setName(String name) {
+		_name = name;
+	}
+
+	/**
+	 * @hibernate.property column="VALUE" type="string"  insert="false" update="false"
+	 */
+	public String getValue() {
+		return _value;
+	}
+
+	public void setValue(String value) {
+		_value = value;
+	}
+
+	public boolean equals(Object another) {
+		return super.equals(another);
+	}
+}
\ No newline at end of file

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HPartnerLink.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HPartnerLink.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HPartnerLink.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HPartnerLink.java Fri Oct 31 16:49:23 2008
@@ -28,8 +28,12 @@
  * configuration).
  * 
  * @hibernate.class table="BPEL_PLINK_VAL"
+ * @hibernate.query name="DELETE_PARTNER_LINKS_BY_INSTANCE" query="delete from HPartnerLink as l where l.scope in (select s from HScope as s where s.instance = :instance)"
+ * @hibernate.query name="DELETE_PARTNER_LINKS_BY_PROCESS" query="delete from HPartnerLink as l where l.scope in (select s.id from HScope as s where s.instance.process = :process)"
  */
 public class HPartnerLink extends HObject {
+	public final static String DELETE_PARTNER_LINKS_BY_INSTANCE = "DELETE_PARTNER_LINKS_BY_INSTANCE";
+	public final static String DELETE_PARTNER_LINKS_BY_PROCESS = "DELETE_PARTNER_LINKS_BY_PROCESS";
 
     private String _linkName;
 
@@ -82,7 +86,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="MYROLE_EPR" cascade="delete"
+     * @hibernate.many-to-one column="MYROLE_EPR" cascade="delete" foreign-key="none"
      */
     public HLargeData getMyEPR() {
         return _myEPR;
@@ -93,7 +97,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="PARTNERROLE_EPR" cascade="delete"
+     * @hibernate.many-to-one column="PARTNERROLE_EPR" cascade="delete" foreign-key="none"
      */
     public HLargeData getPartnerEPR() {
         return _partnerEPR;
@@ -104,7 +108,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="PROCESS"
+     * @hibernate.many-to-one column="PROCESS" foreign-key="none"
      */
     public HProcess getProcess() {
         return _process;
@@ -115,7 +119,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="SCOPE"
+     * @hibernate.many-to-one column="SCOPE" foreign-key="none"
      */
     public HScope getScope() {
         return _scope;
@@ -186,8 +190,7 @@
      *    lazy="true"
      *    inverse="true"
      *    cascade="delete"
-     * @hibernate.collection-key
-     *    column="PARTNERLINK"
+     * @hibernate.collection-key column="PARTNERLINK" foreign-key="none"
      * @hibernate.collection-one-to-many
      *    class="org.apache.ode.daohib.bpel.hobj.HMessageExchange"
      */

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java Fri Oct 31 16:49:23 2008
@@ -74,9 +74,8 @@
      * @hibernate.set
      *  lazy="true"
      *  inverse="true"
-     *  cascade="delete"
      * @hibernate.collection-key
-     *  column="PROCESS"
+     *  column="PROCESS" foreign-key="none"
      * @hibernate.collection-one-to-many
      *   class="org.apache.ode.daohib.bpel.hobj.HMessageExchange"
      */
@@ -94,7 +93,7 @@
      *  inverse="true"
      *  cascade="delete"
      * @hibernate.collection-key
-     *  column="PROCESS_ID"
+     *  column="PROCESS_ID" foreign-key="none"
      * @hibernate.collection-one-to-many
      *   class="org.apache.ode.daohib.bpel.hobj.HCorrelator"
      */
@@ -110,9 +109,8 @@
      * @hibernate.bag
      *  lazy="true"
      *  inverse="true"
-     *  cascade="delete"
      * @hibernate.collection-key
-     *  column="PROCESS_ID"
+     *  column="PROCESS_ID" foreign-key="none"
      * @hibernate.collection-one-to-many
      *  class="org.apache.ode.daohib.bpel.hobj.HProcessInstance"
      */
@@ -128,9 +126,8 @@
      * @hibernate.bag
      *  lazy="true"
      *  inverse="true"
-     *  cascade="delete"
      * @hibernate.collection-key
-     *  column="PID"
+     *  column="PID" foreign-key="none"
      * @hibernate.collection-one-to-many
      *  class="org.apache.ode.daohib.bpel.hobj.HBpelEvent"
      */
@@ -146,8 +143,8 @@
      * Get the partner links values as deployed.
      *
      * @return {@link Set}&lt;{@link HPartnerLink}&gt; with variable values
-     * @hibernate.set lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="PROCESS"
+     * @hibernate.set lazy="true" inverse="true"
+     * @hibernate.collection-key column="PROCESS" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HPartnerLink"
      */
     public Set<HPartnerLink> getDeploymentPartnerLinks() {

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java?rev=709602&r1=709601&r2=709602&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java Fri Oct 31 16:49:23 2008
@@ -28,9 +28,12 @@
  * Hibernate table representing a BPEL process instance.
  * 
  * @hibernate.class table="BPEL_INSTANCE" dynamic-update="true" lazy="true"
+ * @hibernate.query name="DELETE_INSTANCES_BY_PROCESS" query="delete from HProcessInstance as p where p.process = :process"
  */
 public class HProcessInstance extends HObject {
-    /** Foreign key to owner {@link HProcess}. */
+	public static final String DELETE_INSTANCES_BY_PROCESS="DELETE_INSTANCES_BY_PROCESS";
+
+	/** Foreign key to owner {@link HProcess}. */
     private HProcess _process;
 
     /** Foreign key to the instantiating {@link HCorrelator}. */
@@ -74,7 +77,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="INSTANTIATING_CORRELATOR"
+     * @hibernate.many-to-one column="INSTANTIATING_CORRELATOR" foreign-key="none"
      */
     public HCorrelator getInstantiatingCorrelator() {
         return _instantiatingCorrelator;
@@ -85,7 +88,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="FAULT" cascade="delete" column="FAULT"
+     * @hibernate.many-to-one column="FAULT" column="FAULT" foreign-key="none"
      */
     public HFaultData getFault() {
         return _fault;
@@ -96,7 +99,7 @@
     }
 
     /**
-     * @hibernate.many-to-one column="JACOB_STATE" cascade="delete"
+     * @hibernate.many-to-one column="JACOB_STATE" foreign-key="none"
      */
     public HLargeData getJacobState() {
         return _jacobState;
@@ -107,8 +110,8 @@
     }
 
     /**
-     * @hibernate.bag lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="IID"
+     * @hibernate.bag lazy="true" inverse="true"
+     * @hibernate.collection-key column="IID" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HBpelEvent"
      */
     public Collection<HBpelEvent> getEvents() {
@@ -120,8 +123,8 @@
     }
 
     /**
-     * @hibernate.set lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="PIID"
+     * @hibernate.set lazy="true" inverse="true"
+     * @hibernate.collection-key column="PIID" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HCorrelatorSelector"
      */
     public Set<HCorrelatorSelector> getCorrelatorSelectors() {
@@ -137,8 +140,8 @@
     }
 
     /**
-     * @hibernate.set lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="PIID"
+     * @hibernate.set lazy="true" inverse="true"
+     * @hibernate.collection-key column="PIID" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HMessageExchange"
      */
     public Set<HMessageExchange> getMessageExchanges() {
@@ -162,7 +165,7 @@
 
     /**
      * 
-     * @hibernate.many-to-one column="PROCESS_ID" lazy="false" outer-join="true"
+     * @hibernate.many-to-one column="PROCESS_ID" lazy="false" outer-join="true" foreign-key="none"
      */
     public HProcess getProcess() {
         return _process;
@@ -173,8 +176,8 @@
     }
 
     /**
-     * @hibernate.bag lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="PIID"
+     * @hibernate.bag lazy="true" inverse="true"
+     * @hibernate.collection-key column="PIID" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HScope"
      */
     public Collection<HScope> getScopes() {
@@ -186,8 +189,8 @@
     }
 
     /**
-     * @hibernate.bag lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="PIID"
+     * @hibernate.bag lazy="true" inverse="true"
+     * @hibernate.collection-key column="PIID" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HCorrelationSet"
      */
     public Collection<HCorrelationSet> getCorrelationSets() {
@@ -233,7 +236,7 @@
 
     /**
      * @hibernate.bag lazy="true" inverse="true" cascade="delete"
-     * @hibernate.collection-key column="PIID"
+     * @hibernate.collection-key column="PIID" foreign-key="none"
      * @hibernate.collection-one-to-many class="org.apache.ode.daohib.bpel.hobj.HActivityRecovery"
      */
     public Collection<HActivityRecovery> getActivityRecoveries() {