This content has been marked as final. Show 3 replies
It isn't too productive to ask an OpenJPA question in a Toplink forum - even if they implement the same specification, they're totally different beasts. You'd better find an OpenJPA forum.
In any case the one thing that I can spy from the tiny snippet of code is that you may be using the exact same EntityManager for each query invoked. You should make it such that a unique EntityManager is obtained and cleaned up within each call; in other words each thread will use a private EntityManager instance even when invoking the same method at the same time. That prevents any multithreading issues.
First of all thanks for the prompt response :)
Also, just adding to my original post
I thought this should help and not lead to any thread issues...?
//I create a EM Helper class which gets the EM for any invocations private static final ThreadLocal<EntityManager> threadLocal; // emf = Persistence.createEntityManagerFactory("PU"); //Then i get the EM as follows manager = emf.createEntityManager(); // using ThreadLocal class to avoid unnecessary thread issues threadLocal.set(manager);