tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cocorossello <>
Subject Re: JtaEntityManager GC
Date Tue, 13 Feb 2018 08:42:42 GMT

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:

View raw message