[
https://issues.apache.org/jira/browse/OPENJPA-450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620187#action_12620187
]
Jacek Żoch commented on OPENJPA-450:
------------------------------------
I have the same problem. Is there any workaround known ?
> 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.