[ 
https://issues.apache.org/jira/browse/OPENJPA-450?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nick Johnson updated OPENJPA-450:
---------------------------------

    Attachment: openjpa_testcase.jar

Test case that shows the suboptimal query strategy; includes schema and a 
testcase that will create the schema on a PostgreSQL database.  (At the time I 
started this it wasn't clear where the problem came from so I decided to vary 
as little as possible; otherwise I'd have used something like hsql to make it 
easier.)

> Suboptimal Query strategy for JPA queries that return multiple Entities
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-450
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-450
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: query
>    Affects Versions: 1.0.1
>            Reporter: Nick Johnson
>            Priority: Minor
>         Attachments: openjpa_testcase.jar
>
>
> When a Query returns instances of  multiple Entity classes, the query 
> strategy is suboptimal.  First it issues a query to select all the primary 
> keys, and then additional queries are issued for every one of those primary 
> keys.  If exactly one type of Entity is in the SELECT clause, a much more 
> efficient, single query is constructed.
> I'll attach a test case that demonstrates this.  Watch what happens when this:
>               Query q = em.createQuery("Select message, article from Message 
> message, Article article  "
> is changed to this:
>               Query q = em.createQuery("Select message from Message message, 
> Article article  "
> in terms of which SQL statements are executed.
> FYI,  there's more detail on the users list with the subject, "how to avoid 
> large number of queries" and Patrick Linskey and I have emailed back and 
> forth a bit about it.  I'm opening this as a nicer way of keeping track of 
> the issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to