Calling entityManager.clear() seems the best approach since most of the
queries are not executed inside a transaction. But I have no idea on where I
should use it or what would be a good implementation pattern.

I mean, let's say I have a @ViewScoped with a couple of injected

public class MyViewBean{

private MyRepo1 myRepo1;

private MyRepo2 myRepo2;

void init(){
   someVar1= myRepo1.loadSomeStuff();
   someVar2 = myRepo2.loadSomeStuff();

public class MyRepo1{
    @PersistenceContext(unitName = "myUnit")
    private EntityManager entityManager;

    public List<Something> loadSomeStuff(){  //Non transactional


So, should I call entityManager.clear() after all non transactional queries
(or at least some of them)? Can I do it in some web filter? 

This seems pretty basic stuff but I can't get it right...

Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html

Reply via email to