Hi ,
I am unable to replicate your issue with a simple test case.
You can download the testcase from:
http://n2.nabble.com/file/n3258038/openJPATestCase.zip openJPATestCase.zip
There is a readme file which explains how to run the testcase.
I get the following output :
test:
[java] 62 openjpaConf INFO [main] openjpa.Runtime - Starting
OpenJPA 2.0.0-SNAPSHOT
[java] 187 openjpaConf INFO [main] openjpa.jdbc.JDBC - Using
dictionary class "org.apache.o
penjpa.jdbc.sql.OracleDictionary".
[java] 2437 openjpaConf TRACE [main] openjpa.jdbc.SQL - <t 2098848,
conn 9633996> executing
prepstmnt 12893236 SELECT t0.id, t0.DATE0, t0.name FROM EntityC t0 WHERE
(t0.DATE0 = ?) [params=(Timestamp) 2001-01-01 01:01:00.0]
[java] 2578 openjpaConf TRACE [main] openjpa.jdbc.SQL - <t 2098848,
conn 9633996> [141 ms] spent
[java] Mon Jan 01 01:01:00 MST 2001
[java] aname
[java] Mon Jan 01 01:01:00 MST 2001
[java] aname2
BUILD SUCCESSFUL
Also in your debug I see the following:
[7/14/09 16:57:50:475 MSD] R 266 MainPersistence TRACE openjpa.jdbc.SQL
- <t 1495423266, conn 1329090360> executing prepstmnt 1388597956 SELECT
t0.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:631 MSD] R 422 MainPersistence TRACE [WebContainer : 2]
openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> executing prepstmnt
646850190 SELECT t0.mask, t0.acc_name, t0.acc_seq, t0.value FROM ACCOUNT t0
WHERE 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
What is the “[WebContainer : 2]” above and why does it not appear in the
first query ?
Regards,
Ravi.
om wrote:
>
> Hi!
>
> I'm new with openJPA, and didn't manage to get over the problem with
> simple select statement for one object after a few days of
> investigation. Please help!
>
> For simple select from one object, OpenJPA ( same strategy for 1.0,
> 1.2.1, 2.0 ) fist generates right query to retrieve all fields, and then
> start generating query per object by primary key.
>
> Code :
> StringBuffer queryBuf = new StringBuffer("SELECT a FROM Account AS
> a WHERE 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 target query "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]
> with parameters: {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 SELECT t0.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 SELECT t0.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
> prepstmnt 646850190 SELECT t0.mask, t0.acc_name, t0.acc_seq, t0.value
> FROM ACCOUNT t0 WHERE 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
> prepstmnt 2146074602 SELECT t0.mask, t0.acc_name, t0.acc_seq, t0.value
> FROM ACCOUNT t0 WHERE 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 and fields.
> 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
> and wrap works 1.5 sec. I've tried different query hints and a few
> openjpa versions, but with no result.
>
>
> Best regards,
> Mikhail V. Ostryanin
> Sr.Developer/Analyst
> UBS, Moscow
> Tel: +7 495 648 22 14
> [email protected]
>
>
>
> Visit our website at http://www.ubs.com
>
> This message contains confidential information and is intended only
> for the individual named. If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
>
> E-mails are not encrypted and cannot be guaranteed to be secure or
> error-free as information could be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses. The sender
> therefore does not accept liability for any errors or omissions in the
> contents of this message which arise as a result of e-mail transmission.
> If verification is required please request a hard-copy version. This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities
> or related financial instruments.
>
>
> UBS reserves the right to retain all messages. Messages are protected
> and accessed only in legally justified cases.
>
http://n2.nabble.com/file/n3258038/openJPATestCase.zip openJPATestCase.zip
--
View this message in context:
http://n2.nabble.com/openJPA-generates-select-per-row---impossible-to-use-for-select-statements-tp3257267p3258038.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.