persistence@glassfish.java.net

Re: Persistence Test Integrated in QuickLook

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 31 Oct 2005 13:06:28 -0800

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();
>