Author: jeff.yuchang
Date: 2010-09-19 20:53:39 -0400 (Sun, 19 Sep 2010)
New Revision: 950
Modified:
branches/RiftSaw-ODE-2.1.x/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java
Log:
* RIFTSAW-285 fixed the EntityNotFoundException issue.
Modified:
branches/RiftSaw-ODE-2.1.x/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java
===================================================================
---
branches/RiftSaw-ODE-2.1.x/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java 2010-09-17
07:32:10 UTC (rev 949)
+++
branches/RiftSaw-ODE-2.1.x/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java 2010-09-20
00:53:39 UTC (rev 950)
@@ -68,8 +68,9 @@
@NamedQuery(name=ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS,
query="select i._instanceId from ProcessInstanceDAOImpl as i where i._process =
:process"),
@NamedQuery(name=ProcessInstanceDAOImpl.COUNT_INSTANCE_IDS_BY_PROCESS,
query="select count(i._instanceId) from ProcessInstanceDAOImpl as i where i._process
= :process"),
@NamedQuery(name=ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS,
query="select i._faultId from ProcessInstanceDAOImpl as i where i._process = :process
and i._faultId is not null"),
-
@NamedQuery(name=ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID,
- query="select count(i._instanceId), max(i._lastRecovery) from
ProcessInstanceDAOImpl as i where i._process._processId = :processId and i._state
in(:states) and exists(select r from ActivityRecoveryDAOImpl r where i =
r._instance)")
+
@NamedQuery(name=ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID,
+ query="select count(i._instanceId), max(i._lastRecovery) from
ProcessInstanceDAOImpl as i where i._process._processId = :processId and i._state
in(:states) and exists(select r from ActivityRecoveryDAOImpl r where i =
r._instance)"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.DELETE_INSTANCE_BY_ID, query="delete
from ProcessInstanceDAOImpl as p where p._instanceId = :instanceId")
})
public class ProcessInstanceDAOImpl extends BpelDAO implements ProcessInstanceDAO {
private static final Log __log = LogFactory.getLog(ProcessInstanceDAOImpl.class);
@@ -81,6 +82,8 @@
public final static String SELECT_FAULT_IDS_BY_PROCESS =
"SELECT_FAULT_IDS_BY_PROCESS";
public final static String COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID =
"COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID";
+ public final static String DELETE_INSTANCE_BY_ID =
"DELETE_INSTANCE_BY_ID";
+
@Id @Column(name="ID")
@GeneratedValue(strategy=GenerationType.AUTO)
private Long _instanceId;
@@ -103,7 +106,7 @@
private ScopeDAOImpl _rootScope;
@OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_processInstance",fetch=FetchType.LAZY,cascade={CascadeType.MERGE,
CascadeType.PERSIST, CascadeType.REFRESH})
private Collection<ScopeDAO> _scopes = new ArrayList<ScopeDAO>();
-
@OneToMany(targetEntity=ActivityRecoveryDAOImpl.class,mappedBy="_instance",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+
@OneToMany(targetEntity=ActivityRecoveryDAOImpl.class,mappedBy="_instance",fetch=FetchType.LAZY,cascade={CascadeType.MERGE,
CascadeType.PERSIST, CascadeType.REFRESH})
private Collection<ActivityRecoveryDAO> _recoveries = new
ArrayList<ActivityRecoveryDAO>();
@SuppressWarnings("unused")
@@ -167,6 +170,7 @@
// by default, we do not flush before select; flush it, so we can delete
no matter if an entity is loaded up
// or not; more importantly, OpenJPA will secretly load from the entire
table if some entities reside only
// in memory
+
getEM().flush();
}
@@ -194,7 +198,9 @@
if( _fault != null ) {
getEM().remove(_fault);
}
- getEM().remove(this); // This deletes ActivityRecoveryDAO
+
+
getEM().createNamedQuery(ActivityRecoveryDAOImpl.DELETE_ACTIVITY_RECOVERIES_BY_IDS).setParameter("ids",
getInstanceId()).executeUpdate();
+
getEM().createNamedQuery(DELETE_INSTANCE_BY_ID).setParameter("instanceId",
getInstanceId()).executeUpdate();
}
@SuppressWarnings("unchecked")
Show replies by date