Are your Read operations and Update operations using the same Entity manager? Why do you need access to the dirty objects anyway?
Thanks, Rick On Mon, Apr 4, 2011 at 10:54 AM, chintan4181 <[email protected]> wrote: > Hi, > > In my project we are exposing stateless ejb and exposed to other system as > a > web service. it has CRUD operations. During Read operation, i am fetching > object from database. and make a change in this object. After that i am > calling Update operation to check whether there are any dirty objects or > not. But it doesn't give me any dirty objects. My code snippet is as below: > > //get the entity manager using @persistentcontext > @PersistentContext > private EntityManager em; > > Read():Loan loan = (Loan) em.createNamedQuery("findByCert_ID", Loan.class) > .setParameter("Cert_ID", certId) > .getSingleResult(); > loan.setLoan_Amount(200000); > > Update(): > OpenJPAEntityManager oem = OpenJPAPersistence.cast(em); > > Collection dirtyObjects =oem.getDirtyObjects(); > LOG.info("Dirty Objects:" +dirtyObjects.size()); //this > prints 0 > > I am getting collection.size = 0. > Doest the EntityManager(em) is closed after read operation? Can somebody > explain me? How do i know which objects are dirty in update()? > > > Thanks > chintan >
