Hi,Could I ask again what the code is doing, following the query.getResultList() ?
Where is the list of results being used? Are the results being serialized or detached?
Thanks, Craig On Jul 15, 2009, at 12:19 AM, om wrote:
Hi All!I’m new in openJPA, and didn’t manage to get over the problem with simple select statement for one object after a few days of investigation. Pleasehelp!For simple select from one object, OpenJPA ( same strategy for 1.0, 1.2.1, 2.0 ) fist generates right query to retrieve all rows and fields, and thenstart generating query per object by primary key. Code :StringBuffer queryBuf = new StringBuffer("SELECT a FROM Account AS aWHERE a.date = :date "); PersistenceProviderImpl impl = new PersistenceProviderImpl(); OpenJPAEntityManagerFactory fac =impl.createEntityManagerFactory("MainPersistence", System.getProperties());OpenJPAEntityManager man = fac.createEntityManager(); Query query = man.createQuery(queryBuf.toString()); query.setParameter("date", reportDate); List res = query.getResultList(); LOG TRACE[7/14/09 16:57:50:475 MSD] R 266 MainPersistence TRACE openjpa.Runtime - Query "SELECT a FROM Account AS a WHERE a.date = :date " is cached as targetquery "null"[7/14/09 16:57:50:475 MSD] R 266 MainPersistence TRACE openjpa.Query - Executing query: [SELECT a FROM Account AS a WHERE a.date = :date] withparameters: {date=java.util.GregorianCalendar[]}[7/14/09 16:57:50:475 MSD] R 266 MainPersistence TRACE openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> executing prepstmnt 1388597956 SELECTt0.id, t0.version, t0.cur_code, t0.acc_date, t0.mask, t0.acc_name, t0.acc_seq, t0.value FROM ACCOUNT t0 WHERE (t0.acc_date = ?) [params=(Timestamp) 2009-07-03 00:00:00.0][7/14/09 16:57:50:553 MSD] R 344 MainPersistence TRACE openjpa.jdbc.SQL -<t 1495423266, conn 1329090360> [78 ms] spent[7/14/09 16:57:50:553 MSD] R 344 MainPersistence TRACE openjpa.jdbc.SQL -<t 1495423266, conn 1329090360> executing prepstmnt 139855958 SELECTt0.mask, t0.acc_name, t0.acc_seq, t0.value FROM ACCOUNT t0 WHERE t0.id = ?[params=(long) 328][7/14/09 16:57:50:631 MSD] R 422 MainPersistence TRACE [WebContainer : 2]openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> [78 ms] spent[7/14/09 16:57:50:631 MSD] R 422 MainPersistence TRACE [WebContainer : 2]openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> executing prepstmnt646850190 SELECT t0.mask, t0.acc_name, t0.acc_seq, t0.value FROM ACCOUNT t0WHERE t0.id = ? [params=(long) 329][7/14/09 16:57:50:709 MSD] R 500 MainPersistence TRACE [WebContainer : 2]openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> [78 ms] spent[7/14/09 16:57:50:709 MSD] R 500 MainPersistence TRACE [WebContainer : 2]openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> executing prepstmnt2146074602 SELECT t0.mask, t0.acc_name, t0.acc_seq, t0.value FROM ACCOUNT t0WHERE t0.id = ? [params=(long) 330][7/14/09 16:57:50:787 MSD] R 578 MainPersistence TRACE [WebContainer : 2]openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> [78 ms] spent ………………………………..I need just list of detached objects to show it in grid. As it’s seen from log trace above, first query is enough to return all necessary objects andfields.Why OpenJPA makes select per object after that? In this case simple code above works 37 seconds for retrieving 440 rows, since same jdbc select andwrap works 1.5 sec. I’ve tried different query hints and a few openjpa versions, but with no result. -- View this message in context: http://n2.nabble.com/openJPA-generates-select-per-row---impossible-to-use-for-simple-select-statements-tp3261512p3261512.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Craig L Russell Architect, Sun Java Enterprise System http://db.apache.org/jdo 408 276-5638 mailto:[email protected] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
