Hi,

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
@ApplicationScoped. 

@ViewScoped
public class MyViewBean{

@Inject
private MyRepo1 myRepo1;

@Inject
private MyRepo2 myRepo2;

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

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

    public List<Something> loadSomeStuff(){  //Non transactional
        entityManager.createQuery(....).getResultList();
    }
}

}

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