Author: jeff.yuchang
Date: 2010-05-25 13:08:23 -0400 (Tue, 25 May 2010)
New Revision: 665
Modified:
branches/ODE/ODE-1.x-jpa/dao-jpa/pom.xml
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAOConnectionImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfDaoImpl.java
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/resources/META-INF/persistence.xml
Log:
* fix the failed test cases in bpel-store module.
Modified: branches/ODE/ODE-1.x-jpa/dao-jpa/pom.xml
===================================================================
--- branches/ODE/ODE-1.x-jpa/dao-jpa/pom.xml 2010-05-25 16:45:03 UTC (rev 664)
+++ branches/ODE/ODE-1.x-jpa/dao-jpa/pom.xml 2010-05-25 17:08:23 UTC (rev 665)
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.soa.bpel</groupId>
<artifactId>riftsaw-dao-jpa</artifactId>
- <name>ODE :: OpenJPA DAO Impl</name>
+ <name>ODE :: JPA DAO Impl</name>
<parent>
<groupId>org.jboss.soa.bpel</groupId>
Modified:
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java
===================================================================
---
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java 2010-05-25
16:45:03 UTC (rev 664)
+++
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/BpelDAOConnectionImpl.java 2010-05-25
17:08:23 UTC (rev 665)
@@ -53,15 +53,13 @@
import org.apache.ode.dao.jpa.JpaConnection;
import org.apache.ode.dao.jpa.JpaOperator;
import org.apache.ode.utils.ISO8601DateParser;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.apache.openjpa.persistence.OpenJPAQuery;
/**
* @author Matthieu Riou <mriou at apache dot org>
*/
public class BpelDAOConnectionImpl extends JpaConnection implements BpelDAOConnection {
static final Log __log = LogFactory.getLog(BpelDAOConnectionImpl.class);
-
+
static final ThreadLocal<BpelDAOConnectionImpl> _connections = new
ThreadLocal<BpelDAOConnectionImpl>();
public BpelDAOConnectionImpl(EntityManager mgr, TransactionManager txMgr, JpaOperator
operator) {
@@ -71,7 +69,7 @@
public static ThreadLocal<BpelDAOConnectionImpl> getThreadLocal() {
return _connections;
}
-
+
public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter,
BpelEventFilter efilter) {
// TODO
@@ -85,33 +83,42 @@
}
public ProcessInstanceDAO getInstance(Long iid) {
+ _txCtx.begin();
ProcessInstanceDAOImpl instance = _em.find(ProcessInstanceDAOImpl.class, iid);
+ _txCtx.commit();
return instance;
}
public MessageExchangeDAO createMessageExchange(char dir) {
+ _txCtx.begin();
MessageExchangeDAOImpl ret = new MessageExchangeDAOImpl(dir);
_em.persist(ret);
+ _txCtx.commit();
return ret;
}
public ProcessDAO createProcess(QName pid, QName type, String guid, long version) {
+ _txCtx.begin();
ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,version);
_em.persist(ret);
+ _txCtx.commit();
return ret;
}
public ProcessDAO createTransientProcess(Serializable id) {
+ _txCtx.begin();
ProcessDAOImpl ret = new ProcessDAOImpl(null, null, null, 0);
ret.setId((Long)id);
-
+ _txCtx.commit();
return ret;
}
@SuppressWarnings("unchecked")
public ProcessDAO getProcess(QName processId) {
+ _txCtx.begin();
List l = _em.createQuery("select x from ProcessDAOImpl x where x._processId
= ?1")
.setParameter(1, processId.toString()).getResultList();
+ _txCtx.commit();
if (l.size() == 0) return null;
ProcessDAOImpl p = (ProcessDAOImpl) l.get(0);
return p;
@@ -125,10 +132,14 @@
}
public ScopeDAO getScope(Long siidl) {
- return _em.find(ScopeDAOImpl.class, siidl);
+ _txCtx.begin();
+ ScopeDAO dao = _em.find(ScopeDAOImpl.class, siidl);
+ _txCtx.commit();
+ return dao;
}
public void insertBpelEvent(BpelEvent event, ProcessDAO process, ProcessInstanceDAO
instance) {
+ _txCtx.begin();
EventDAOImpl eventDao = new EventDAOImpl();
eventDao.setTstamp(new Timestamp(System.currentTimeMillis()));
eventDao.setType(BpelEvent.eventName(event));
@@ -142,6 +153,7 @@
eventDao.setScopeId(((ScopeEvent) event).getScopeId());
eventDao.setEvent(event);
_em.persist(eventDao);
+ _txCtx.commit();
}
private static String dateFilter(String filter) {
@@ -159,6 +171,7 @@
@SuppressWarnings("unchecked")
public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria) {
+ _txCtx.begin();
StringBuffer query = new StringBuffer();
query.append("select pi from ProcessInstanceDAOImpl as pi left join fetch
pi._fault ");
@@ -303,8 +316,7 @@
// criteria limit
Query pq = _em.createQuery(query.toString());
- OpenJPAQuery kq = OpenJPAPersistence.cast(pq);
- kq.getFetchPlan().setFetchBatchSize(criteria.getLimit());
+ getJPADaoOperator().setBatchSize(pq, criteria.getLimit());
List<ProcessInstanceDAO> ql = pq.getResultList();
Collection<ProcessInstanceDAO> list = new
ArrayList<ProcessInstanceDAO>();
@@ -314,7 +326,7 @@
ProcessInstanceDAO processInstanceDAO = (ProcessInstanceDAO)
iterator.next();
list.add(processInstanceDAO);
}
-
+ _txCtx.commit();
return list;
}
@@ -324,11 +336,16 @@
}
public MessageExchangeDAO getMessageExchange(String mexid) {
- return _em.find(MessageExchangeDAOImpl.class, mexid);
+ _txCtx.begin();
+ MessageExchangeDAO dao = _em.find(MessageExchangeDAOImpl.class, mexid);
+ _txCtx.commit();
+ return dao;
}
public void deleteMessageExchange(MessageExchangeDAO mexDao) {
+ _txCtx.begin();
_em.remove(mexDao);
+ _txCtx.commit();
}
public EntityManager getEntityManager() {
@@ -340,6 +357,7 @@
if (instances.size() == 0) {
return new HashMap<Long, Collection<CorrelationSetDAO>>();
}
+ _txCtx.begin();
ArrayList<Long> iids = new ArrayList<Long>(instances.size());
for (ProcessInstanceDAO dao: instances) {
iids.add(dao.getInstanceId());
@@ -355,12 +373,16 @@
}
existing.add(cset);
}
+ _txCtx.commit();
return map;
}
@SuppressWarnings("unchecked")
public Collection<CorrelationSetDAO> getActiveCorrelationSets() {
- return
_em.createNamedQuery(CorrelationSetDAOImpl.SELECT_ACTIVE_SETS).setParameter("state",
ProcessState.STATE_ACTIVE).getResultList();
+ _txCtx.begin();
+ Collection<CorrelationSetDAO> dao =
_em.createNamedQuery(CorrelationSetDAOImpl.SELECT_ACTIVE_SETS).setParameter("state",
ProcessState.STATE_ACTIVE).getResultList();
+ _txCtx.commit();
+ return dao;
}
public ProcessManagementDAO getProcessManagement() {
Modified:
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAOConnectionImpl.java
===================================================================
---
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAOConnectionImpl.java 2010-05-25
16:45:03 UTC (rev 664)
+++
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ConfStoreDAOConnectionImpl.java 2010-05-25
17:08:23 UTC (rev 665)
@@ -37,8 +37,9 @@
* @author Matthieu Riou <mriou at apache dot org>
*/
public class ConfStoreDAOConnectionImpl extends JpaConnection implements
ConfStoreDAOConnection {
+
private static Log LOG = LogFactory.getLog(ConfStoreDAOConnectionImpl.class);
-
+
static final ThreadLocal<ConfStoreDAOConnectionImpl> _connections = new
ThreadLocal<ConfStoreDAOConnectionImpl>();
@@ -50,23 +51,33 @@
}
public DeploymentUnitDAO createDeploymentUnit(String name) {
+ _txCtx.begin();
DeploymentUnitDaoImpl du = new DeploymentUnitDaoImpl();
du.setName(name);
du.setDeployDate(new Date());
_em.persist(du);
+ _txCtx.commit();
return du;
}
public DeploymentUnitDAO getDeploymentUnit(String name) {
- return _em.find(DeploymentUnitDaoImpl.class, name);
+ _txCtx.begin();
+ DeploymentUnitDAO dao= _em.find(DeploymentUnitDaoImpl.class, name);
+ _txCtx.commit();
+ return dao;
}
public Collection<DeploymentUnitDAO> getDeploymentUnits() {
- return _em.createQuery("SELECT du from DeploymentUnitDaoImpl
du").getResultList();
+ _txCtx.begin();
+ Collection<DeploymentUnitDAO> dao = _em.createQuery("SELECT du from
DeploymentUnitDaoImpl du").getResultList();
+ _txCtx.commit();
+ return dao;
}
public long getNextVersion() {
+ _txCtx.begin();
List<VersionTrackerDAOImpl> res = _em.createQuery("select v from
VersionTrackerDAOImpl v").getResultList();
+ _txCtx.commit();
if (res.size() == 0) return 1;
else {
VersionTrackerDAOImpl vt = res.get(0);
@@ -75,16 +86,17 @@
}
public void setVersion(long version) {
+ _txCtx.begin();
List<VersionTrackerDAOImpl> res = _em.createQuery("select v from
VersionTrackerDAOImpl v").getResultList();
VersionTrackerDAOImpl vt;
if (res.size() == 0) vt = new VersionTrackerDAOImpl();
else vt = res.get(0);
vt.setVersion(version);
_em.persist(vt);
+ _txCtx.commit();
}
public static ThreadLocal<ConfStoreDAOConnectionImpl> getThreadLocal() {
return _connections;
}
-
}
Modified:
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfDaoImpl.java
===================================================================
---
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfDaoImpl.java 2010-05-25
16:45:03 UTC (rev 664)
+++
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/java/org/apache/ode/dao/jpa/store/ProcessConfDaoImpl.java 2010-05-25
17:08:23 UTC (rev 665)
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.Map;
/**
* @author Matthieu Riou <mriou at apache dot org>
@@ -44,7 +45,7 @@
@OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL})
@MapKey(name="_key")
@JoinTable(name="STORE_PROC_TO_PROP", inverseJoinColumns={ @JoinColumn(name
= "STORE_PROPERTY_ID")})
- private HashMap<String,ProcessConfPropertyDaoImpl> _properties = new
HashMap<String,ProcessConfPropertyDaoImpl>();
+ private Map<String,ProcessConfPropertyDaoImpl> _properties = new
HashMap<String,ProcessConfPropertyDaoImpl>();
@Id @Column(name="PID")
private String _processId;
Modified: branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/resources/META-INF/persistence.xml
===================================================================
---
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/resources/META-INF/persistence.xml 2010-05-25
16:45:03 UTC (rev 664)
+++
branches/ODE/ODE-1.x-jpa/dao-jpa/src/main/resources/META-INF/persistence.xml 2010-05-25
17:08:23 UTC (rev 665)
@@ -20,27 +20,29 @@
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0">
- <persistence-unit name="ode-dao">
- <!--
- This properties file is used specifically by the
- OpenJPA Enhancer.
- -->
-
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
- <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</class>
- <class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class>
- <class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class>
- <class>org.apache.ode.dao.jpa.EventDAOImpl</class>
- <class>org.apache.ode.dao.jpa.FaultDAOImpl</class>
- <class>org.apache.ode.dao.jpa.MessageDAOImpl</class>
- <class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class>
- <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class>
- <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class>
- <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class>
- <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class>
- <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class>
- <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class>
- <class>org.apache.ode.dao.jpa.CorrSetProperty</class>
- <class>org.apache.ode.dao.jpa.MexProperty</class>
- <class>org.apache.ode.dao.jpa.XmlDataProperty</class>
+ <persistence-unit name="ode-bpel" transaction-type="JTA">
+ <class>org.apache.ode.dao.jpa.bpel.ActivityRecoveryDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelationSetDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrelatorDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.EventDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.FaultDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageExchangeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.MessageRouteDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.PartnerLinkDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ProcessInstanceDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.ScopeDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataDAOImpl</class>
+ <class>org.apache.ode.dao.jpa.bpel.CorrSetProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.MexProperty</class>
+ <class>org.apache.ode.dao.jpa.bpel.XmlDataProperty</class>
</persistence-unit>
+ <persistence-unit name="ode-store" transaction-type="JTA">
+ <class>org.apache.ode.dao.jpa.store.ProcessConfDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.ProcessConfPropertyDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.DeploymentUnitDaoImpl</class>
+ <class>org.apache.ode.dao.jpa.store.VersionTrackerDAOImpl</class>
+ </persistence-unit>
+
</persistence>
\ No newline at end of file