package org.apache.ode.dao.jpa.ojpa;


import java.util.Properties;

import org.apache.ode.bpel.dao.BpelDAOConnection;
import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
import org.apache.ode.dao.jpa.BPELDAOConnectionImpl;

public class BPELDAOConnectionFactoryImpl implements BpelDAOConnectionFactory {

	public BpelDAOConnection getConnection() {
		return new BPELDAOConnectionImpl();
	}

	public void init(Properties properties) {
	}

}

@@ -52,26 +52,126 @@
 va.util.
-Properties
+List;%0D%0Aimport java.util.Properties;%0D%0A%0D%0Aimport javax.persistence.EntityManager;%0D%0Aimport javax.persistence.Query
 ;%0D%0A%0D%0Aimp
@@ -421,85 +421,971 @@
 %0D%0A%09p
-ublic BpelDAOConnection getConnection() %7B%0D%0A%09%09return new BPELDAOConnectionImpl
+rivate EntityManager em;%0D%0A%09%0D%0A%09public BPELDAOConnectionFactoryImpl(EntityManager em) %7B%0D%0A%09%09this.em = em;%0D%0A%09%7D%0D%0A%09%0D%0A%09public BpelDAOConnection getConnection() %7B%0D%0A%09%09%0D%0A%09%09Query q = em.createQuery(%22SELECT x FROM BPELDAOConnectionImpl x order by x._id asc%22);%0D%0A%09%09%0D%0A%09%09List%3CBpelDAOConnection%3E conns = (List%3CBpelDAOConnection%3E)q.getResultList();%0D%0A%09%09%0D%0A%09%09if ( conns.size() %3C 1 ) %7B%0D%0A%09%09%09return new BPELDAOConnectionImpl(new Long(1));%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09return conns.get(conns.size()-1);%0D%0A%09%7D%0D%0A%09%0D%0A%09public BpelDAOConnection getConnection(Long connID) %7B%0D%0A%09%09%0D%0A%09%09Query q = em.createQuery(%22SELECT x FROM BPELDAOConnectionImpl x WHERE x._id = ?1%22);%0D%0A%09%09q.setParameter(1, connID);%0D%0A%09%09%0D%0A%09%09BpelDAOConnection conn = (BpelDAOConnection)q.getSingleResult();%0D%0A%09%09%0D%0A%09%09if ( conn == null ) %7B%0D%0A%09%09%09conn = new BPELDAOConnectionImpl(connID);%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09return conn;%0D%0A%09%7D%0D%0A%09%0D%0A%09public Long getConnectionId(BpelDAOConnection conn) %7B%0D%0A%09%09BPELDAOConnectionImpl oConn = (BPELDAOConnectionImpl)conn;%0D%0A%09%09return oConn.getID
 ();%0D

Add connection control