Normally select does not require transaction. Can you take out
em.getTransaction().begin();
em.getTransaction().commit();
and run your application again to see if there is any exception thrown for the update statements?
Fay
----- Original Message ----
From: Pieter Pareit <
[hidden email]>
To:
[hidden email]
Sent: Thursday, August 27, 2009 12:10:34 AM
Subject: Simple Select generates extra SQL statements to UPDATE Entities
Hi,
A simple select statement generates update statements afterwards.
// ----------------------- CODE
EntityManagerFactory factory =
Persistence.createEntityManagerFactory("openjpa");
EntityManager em = factory.createEntityManager();
em.getTransaction().begin();
List<CompanyEffDate> rows = em.createQuery("SELECT c FROM CompanyEffDate as
c LEFT OUTER JOIN FETCH c.companyAddresses").getResultList();
for(CompanyEffDate companyEffDate : rows){
System.out.println("companyName: "+ companyEffDate.getId());
System.out.println("companyAddress size: "+
companyEffDate.getCompanyAddresses().size());
}
em.getTransaction().commit();
em.close();
// -------------- LOGGING
813 openjpa TRACE [TP-Processor3] openjpa.jdbc.SQL - <t 13468632, conn
640013
3> executing prepstmnt 17122634 SELECT t0.effectiveDate, t0.id, t0.name,
t1.comp
anyId, t1.effectiveDate, t1.id, t1.postal FROM company t0 LEFT OUTER JOIN
compan
yaddress t1 ON t0.id = t1.companyId ORDER BY t1.companyId ASC
819 openjpa TRACE [TP-Processor3] openjpa.jdbc.SQL - <t 13468632, conn
640013
3> [1 ms] spent
companyName: 19a06d80-3ca1-4ffa-8052-f4a88b1b66e1
companyAddress size: 0
companyName: b7977af7-c3f9-4e0b-a7f8-864886beec3e
companyAddress size: 1
911 openjpa TRACE [TP-Processor3] openjpa.jdbc.SQL - <t 13468632, conn
784712
5> executing prepstmnt 18220809 UPDATE companyaddress SET companyId = ?,
postal
= ? WHERE effectiveDate = ? AND id = ? [params=(String)
b7977af7-c3f9-4e0b-a7f8-
864886beec3e, (String) 1000, (Timestamp) 2009-08-26 15:38:42.0, (String)
89c30f0
e-4c83-4560-a92f-87165154a6b4]
919 openjpa TRACE [TP-Processor3] openjpa.jdbc.SQL - <t 13468632, conn
784712
5> [0 ms] spent
923 openjpa TRACE [TP-Processor3] openjpa.jdbc.SQL - <t 13468632, conn
784712
5> executing prepstmnt 17721367 UPDATE company SET name = ? WHERE
effectiveDate
= ? AND id = ? [params=(String) Ignacio Andreu, (Timestamp) 2009-08-26
15:38:42.
0, (String) b7977af7-c3f9-4e0b-a7f8-864886beec3e]
929 openjpa TRACE [TP-Processor3] openjpa.jdbc.SQL - <t 13468632, conn
784712
5> [1 ms] spent
932 openjpa TRACE [TP-Processor3] openjpa.jdbc.SQL - <t 13468632, conn
784712
5> executing prepstmnt 13889218 UPDATE company SET name = ? WHERE
effectiveDate
= ? AND id = ? [params=(String) Ignacio Andreu, (Timestamp) 2009-08-26
15:39:02.
0, (String) 19a06d80-3ca1-4ffa-8052-f4a88b1b66e1]
939 openjpa TRACE [TP-Processor3] openjpa.jdbc.SQL - <t 13468632, conn
784712
5> [1 ms] spent
Thanks in advance,
Pieter Pareit
http://www.easypay-group.com--
View this message in context:
http://n2.nabble.com/Simple-Select-generates-extra-SQL-statements-to-UPDATE-Entities-tp3521916p3521916.htmlSent from the OpenJPA Developers mailing list archive at Nabble.com.