s.grinovero wrote:
you really shouldn't get, share and reuse a single EntityManager instance for your whole application, but use a new one in each bean requiring it's services; best option is dependency injection;
If you really need a static variable you may try to keep reference to an EntityManagerFactory.
Also you shouldn't ever need to flush, I think it has to do with the previous issue but you may also need to integrate your configuration with JBoss, read about JTA:
http://www.hibernate.org/hib_docs/entitymanager/reference/en/html_single/
it's not for the whole application but per impl of a "t extends igenericdao"
i can't use injections because the class itself is not managed by the container but trough a static factory (legacy code) , i have some sort of helper factory
that retreives a helper from a static getinstance and i've created a new class that overides the class and the methods and insted of raw sql and complicated mapping utilize jpa and jpql , but since it's a stateless factory i have to use getEntitymanager (or do i ? )since the A.S doesn't run it's life cycle ( i tough about maybe in getInstace ask from the jndi the real instace ? and that might solve it ) i may have to have change it to a static getfacory and each time let the factory create a new manager ... ?
another problem is that it is packed inside an ear that all but this project are ejb2.1 jars and i'm ejb3 , so the jta is fetched from the appliactionserver .