glassfish « DAO « JPA Q&A





1. Glassfish doesn't bring up EntityManager if DAO is not Stataless    stackoverflow.com

I have an EAR application with an EJB module, that contains one persistence unit and many EJBs (as service and DAO layer).

@Stateless
public class BranchDAO {
    @PersistenceContext
   ...

2. DAO insertOrUpdate() method: how to implement using JPA?    java.net

I should mention that the object being inserted/updated is always coming from a fat client, and is hence pretty much guaranteed to be detached. What puzzles me is the behavior of the merge() method in the case of this-is-a-brand-new-never-persisted-before DTO. I am surprised that this works. Should it? Is it guaranteed to? Is this Glassfish-specific behavior?

3. Glassfish / Hibernate / ejb3 dao issue    java.net

When I call updateRecord() (in the code below) for the 1st time the changes to theRecord are not persisted in the database. When I call updateRecord() for the second time the changes from the 1st call are persisted. I believe that this is due to a new transaction being created for each call, forcing the previous transaction to be committed?