persistence@glassfish.java.net

RE: Persistence Test Integrated in QuickLook

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Tue, 1 Nov 2005 08:17:49 -0500

Marina,
        TopLink is caching the data internally. Generally users have no issue with stale data (outside of the standard concurrency issues) but if the end user has processes modifying the data external to TopLink there are configuration options for handling the external updates. With the EJB 3.0 specification however there is no clear mechanism for providing support for configuring TopLink to handle externally modified data. We are currently evaluating our options and will hopefully have a solution soon.
     In the meantime two options are available. Have the tests clear the objects from the database using the Persistence API or reset the TopLink caches by calling : ((oracle.toplink.essentials.ejb.cmp3.EntityManager)entityManager).getActiveSession().initializeAllIdentityMaps().

--Gordon

-----Original Message-----
From: Marina Vatkina [mailto:Marina.Vatkina_at_Sun.COM]
Sent: Monday, October 31, 2005 4:06 PM
To: Deepa Singh
Cc: Mitesh Meswani; Shelly (Donna) McGowan; Sanjeeb Kumar Sahoo; Michael
Bouschen; Sailaja Rao Gangaraju; persistence
Subject: Re: Persistence Test Integrated in QuickLook


Hi Deepa,

(CC-ing persistence)

Can it be that the record is already there? TopLink code might be
caching results of a previous run. Keep in mind that CMP code uses
completely different code for persistence runtime.

thanks,
-marina

Deepa Singh wrote On 10/31/05 12:52,:
> Hi Marina,
> Persistence Quicklook tests is integrated into GlassFish quicklook test
> base.
> glassfish/appserv-tests/sqetests/ejb/ejb30/persistence/onetomany
>
> There is only one thing missing, when I run my test (execute only client
> )twice (after dropping table and re-creating it), I get following
> exception in my server.log'. I don't see this exception when I run CMP
> 2.1 tests in same mode. I deploy the ear file, and then execute
> appclient multiple times making sure that tests passes
>
> Caused by: java.lang.IllegalArgumentException: Can not PERSIST detatched
> object: pe.ejb.ejb30.persistence.toplinksample.ejb.CustomerEntity_at_f0ca71.
> at
> oracle.toplink.essentials.publicinterface.UnitOfWork.registerNewObjectForPersist(UnitOfWork.java:3131)
> at
> oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:96)
> at
> com.sun.enterprise.util.EntityManagerWrapper.persist(EntityManagerWrapper.java:163)
> at
> pe.ejb.ejb30.persistence.toplinksample.ejb.StatefulBean.runPersistenceTest(StatefulBean.java:25)
>
> Path is as follows:
> appclient-->stateful session-->persistence entities
>
> -stateful session has a method called runPersistenceTest. Please let me
> know how should I code this up,so that test passes after executing just
> client multiple times (cleaning up schema in between runs)
>
> public void runPersistenceTest(){
> CustomerEntity c1=new CustomerEntity(1,"Alice","Santa Clara");
> em.persist(c1);
> CustomerEntity c2=new CustomerEntity(2,"Betty","Sunnyvale");
> em.persist(c2);
> OrderEntity o1=new OrderEntity(100,1);
> em.persist(o1);
> OrderEntity o2=new OrderEntity(101,2);
> em.persist(o2);
> ItemEntity i1=new ItemEntity(100,"Camcorder");
> em.persist(i1);
> List result = em.createQuery("SELECT OBJECT(cust) FROM
> CustomerEntity cust").getResultList();
>