I am having a J2EE application that uses JPA as a persistence framework having transaction type JTA. I am using EntityManager annotated with PersistenceContext. My SessionBean looks like this :
package com.session;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.ejb.LocalBean;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.beans.Bean_B;
/**
* Session Bean implementation class Bean_BSession
*/
@Stateless
@LocalBean
public class Bean_BSession implements Bean_BSessionLocal {
@PersistenceContext(unitName = "bench")
private EntityManager em;
/**
* Default constructor.
*/
public Bean_BSession() {
// TODO Auto-generated constructor stub
}
@Override
public List<Bean_B> findAll(int A_Id) {
// TODO Auto-generated method stub
List<Bean_B> bList = null;
Query q = em
.createQuery("Select b FROM Bean_B b where b.BI_AID = :id");
q.setParameter("id", A_Id);
bList = (List<Bean_B>) q.getResultList();
return bList;
}
@Override
public int delete(int BI_ID) {
// TODO Auto-generated method stub
Query q = em
.createQuery("delete from Bean_B b where b.BI_ID = :id");
q.setParameter("id", BI_ID);
return q.executeUpdate();
}
}
When I put it on a test of multiple user I don't find it scaling though I am having max-pol size of the datasource 200. My Persistence.xml looks like :
<persistence xmlns="http://ift.tt/1cKbVbQ"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/1cKbVbQ
http://ift.tt/1kMb4sd"
version="2.1">
<persistence-unit name="bench">
<jta-data-source>jdbc/benchDS</jta-data-source>
<class>com.beans.Bean_A</class>
<class>com.beans.bean_B</class>
<class>com.beans.Bean_C</class>
<class>com.beans.Bean_D</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
</properties>
</persistence-unit>
</persistence>
Let me know what are the changes I need to incorporate. Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire