openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick" <michael.d.d...@gmail.com>
Subject Re: Non dirty entity version field update SUPER URGENT!!!
Date Tue, 30 Sep 2008 14:07:02 GMT
Hi,

I'm doing something similar :
    @Test
    public void testMergeUnchangedEntityAPIs() {
        EntityManager em = emf.createEntityManager();

        em.getTransaction().begin();
        MyEntity e = new MyEntity();
        e.setName("MyName1");
        em.persist(ct);
        em.getTransaction().commit();
        em.refresh(e);
        int id = e.getId();
        em.clear();
        // could get a new EM here too.

        e = em.getReference(MyEntity.class, id);
        e = ((OpenJPAEntityManager)em).detach(e);
        assertNotNull(e);
        assertFalse(em.contains(e));

        Object eOld = e;
        e = copy(e);
        assertNotSame(eOld, e);

        em.getTransaction().begin();
        em.merge(e);
        em.getTransaction().commit();

        assertNotSQL("UPDATE.*CompanyType.*");

        em.close();
    }

The save method in your example has a couple of interesting methods. You're
setting the OpenJPAEntityManager in the entity, and (potentially) touching
other relationships. Could you elaborate on what these methods do in your
example.

Here's the relevant section of code :

	public Object save(Object object) {
		BaseEntity managedObject = (BaseEntity)em.merge(object);
        managedObject.setOpenJPAEntityManager(oem);
        managedObject.synchAllRelationships();
		return managedObject;
	}


-mike

On Tue, Sep 30, 2008 at 4:13 AM, egoosen <egoosen2@metropolitan.co.za>wrote:

>
> Hi,
>
> I tested again using 1.3.0-SNAPSHOT, and no luck.
>
> Here's the SQL output:
> 187655  status  TRACE  [http-8080-1] openjpa.jdbc.SQL - <t 386451, conn
> 12504947> batching prepstmnt 20910753 UPDATE EBSTATUS.TBL_ADR SET VRS_NBR =
> ? WHERE ADR_ID = ? AND VRS_NBR = ? [params=(int) 26, (int) 1, (int) 25]
> 187655  status  TRACE  [http-8080-1] openjpa.jdbc.SQL - <t 386451, conn
> 12504947> [0 ms] spent
> 187655  status  TRACE  [http-8080-1] openjpa.jdbc.SQL - <t 386451, conn
> 12504947> batching prepstmnt 20910753 UPDATE EBSTATUS.TBL_ADR SET VRS_NBR =
> ? WHERE ADR_ID = ? AND VRS_NBR = ? [params=(int) 27, (int) 2, (int) 26]
> 187655  status  TRACE  [http-8080-1] openjpa.jdbc.SQL - <t 386451, conn
> 12504947> [0 ms] spent
> 187655  status  TRACE  [http-8080-1] openjpa.jdbc.SQL - <t 386451, conn
> 12504947> executing batch prepstmnt 20910753 UPDATE EBSTATUS.TBL_ADR SET
> VRS_NBR = ? WHERE ADR_ID = ? AND VRS_NBR = ? [params=(int) 27, (int) 2,
> (int) 26]
> 187655  status  TRACE  [http-8080-1] openjpa.jdbc.SQL - <t 386451, conn
> 12504947> [0 ms] spent
> 187655  status  TRACE  [http-8080-1] openjpa.jdbc.SQL - <t 386451, conn
> 12504947> executing prepstmnt 31470790 UPDATE EBSTATUS.TBL_FNDMST SET
> VRS_NBR = ? WHERE FND_CDE = ? AND VRS_NBR = ? [params=(int) 30, (String)
> 0000001, (int) 29]
> 187655  status  TRACE  [http-8080-1] openjpa.jdbc.SQL - <t 386451, conn
> 12504947> [0 ms] spent
>
> I also added:
> <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
> ...and didn't get any exception, so all my entities are being properly
> enhanced.
>
> I'm not sure how you have setup your test case to recreate this issue, but
> from my side, these are the steps:
> Retrieve model object
> Detach
> Copy detached object to GWT 1.4 friendly DTO.
> Copy DTO to new model object (preserving version no, and id)
> Attach "new" model object.
> http://n2.nabble.com/file/n1128427/Tester.java Tester.java
>
> Will debug the OpenJPA code and see why this is happening.
>
> Thanks for your help anyway.
>
> Rgds,
> Enrico
>
>
> Jeremy Bauer wrote:
> >
> > I too didn't have any luck reproducing the problem.  I tried 1.2.x and
> > 1.3.0.  Using build-time an the agent enhancer, an update was only
> > issued if a value was changed.  However, runtime enhancement produced
> > a version update.
> >
> > You may want to try disabling runtime/fallback enhancement by adding
> > the property below to your  persistence.xml.  That's a simple way to
> > check if your build-time enhancement worked correctly.  If not, you'll
> > get an exception indicating that an entity has not been enhanced.
> >
> >                 <property name="openjpa.RuntimeUnenhancedClasses"
> > value="unsupported"/>
> >
> > -Jeremy
> >
> >
>
> --
> View this message in context:
> http://n2.nabble.com/Non-dirty-entity-version-field-update-SUPER-URGENT%21%21%21-tp1120307p1128427.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message