Which is basically warp-persist, but integrated into guice. But as far as I know, it will be only be integrated as of guice 3.0;

Bas

Op 10-3-2011 15:29, nino martinez wael schreef:
I'd go for guice persist if thats an option..

2011/3/10 Bas Gooren<b...@iswd.nl>

Have a look at databinder or warp-persist for a better implementation.

Should you go with your own implementation, do not forget to clear the
ThreadLocal at the end of the request to prevent:
a) leaking
b) re-using an EntityManager from a previous request (most if not all
application servers use a thread pool)

Bas

Op 10-3-2011 13:12, Duro schreef:

  Hi guys, is this an option to store the JPA entity manager for a wicket
webapp:
public class DBUtil {
    private static EntityManagerFactory entityManagerFactory = Persistence
            .createEntityManagerFactory("db");
    private static ThreadLocal<EntityManager>  emHolder = new
ThreadLocal<EntityManager>() {
        protected EntityManager initialValue() {
            return entityManagerFactory.createEntityManager();
        };
    };

    public static User getUser(String userName) {
        return emHolder.get().find(User.class, userName);
    }

..................

If not, thanks for possible better solutions, Juraj

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org


Reply via email to