openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ruben Laguna <ruben.lag...@gmail.com>
Subject Re: OpenJPA generates extra UPDATEs
Date Fri, 18 Sep 2009 16:00:52 GMT
Well, now I'm 100% sure that the entity class is enhanced, I see the

5968  persistencexmltest1PU  INFO   [main] openjpa.Enhance - Creating
subclass for "[class com.rubenlaguna.MyEntity]". This means that your
application will be less efficient and will consume more memory than it
would if you ran the OpenJPA enhancer. Additionally, lazy loading will not
be available for one-to-one and many-to-one persistent attributes in types
using field access; they will be loaded eagerly instead.


but I cannot understand I'm running the enhancer (via ant task) and I can
see that the md5 signature of the class file has changed


$ md5sum build/classes/com/rubenlaguna/MyEntity.class
af6dc953c66c328853c5a5dc6062c5d4
*build/classes/com/rubenlaguna/MyEntity.class


$ md5sum build/classes/com/rubenlaguna/MyEntity.class
c47b89c1065fdaeb90cc998c12a997a8
*build/classes/com/rubenlaguna/MyEntity.class

It's there any way to check that the class file is actually properly
enhanced?

Thanks in advance


On Fri, Sep 18, 2009 at 5:17 PM, ecerulm <ruben.laguna@gmail.com> wrote:

>
> Hi,
>
> I have the following snippet of code
>
>
>
>        EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("persistencexmltest1PU");
>        EntityManager em = emf.createEntityManager();
>        for (int i = 0; i < 10; i++) {
>            em.getTransaction().begin();
>            MyEntity n =new MyEntity();
>            n.setValue(i);
>            em.persist(n);
>            em.getTransaction().commit();
>            //em.clear(); //This shouldn't be needed, right?
>        }
>
>
> And OpenJPA 1.2.0 (with HSQLDB) is generating
>
> INSERT INTO MYTABLE (ID, VALUE, CREATED) VALUES (?, ?, ?) [params=(int) 1,
> (int) 0, (null) null]
> INSERT INTO MYTABLE (ID, VALUE, CREATED) VALUES (?, ?, ?) [params=(int) 2,
> (int) 1, (null) null]
> UPDATE MYTABLE SET CREATED = ? WHERE ID = ? [params=(null) null, (int) 1]
> INSERT INTO MYTABLE (ID, VALUE, CREATED) VALUES (?, ?, ?) [params=(int) 3,
> (int) 2, (null) null]
> UPDATE MYTABLE SET CREATED = ? WHERE ID = ? [params=(null) null, (int) 2]
> UPDATE MYTABLE SET CREATED = ? WHERE ID = ? [params=(null) null, (int) 1]
>
>
> The MyEntity entity IS enhanced so I guess that
> https://issues.apache.org/jira/browse/OPENJPA-546 doesn't apply.
>
> If I call EntityManager.clear() after the commit then the issue is fixed.
> But is this the expected behaviour? OpenJPA is generating SQL updates for
> unchanged entities within the transaction, that is not what I was
> expecting.
>
> For me, this started when I added a @Temporal(TemporalType.TIMESTAMP) field
> to the entity (MyEntity). With a "simpler" entity I get only INSERTs (no
> UPDATEs).
>
>
>
>
>
> http://rubenlaguna.com/wp/2009/09/18/openjpa-generated-sql-contains-extra-updates/
>
>
>
>
> --
> View this message in context:
> http://n2.nabble.com/OpenJPA-generates-extra-UPDATEs-tp3670456p3670456.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>



-- 
/Rubén

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