openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nick Johnson (JIRA)" <>
Subject [jira] Updated: (OPENJPA-450) Suboptimal Query strategy for JPA queries that return multiple Entities
Date Fri, 23 Nov 2007 23:43:43 GMT


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:
>             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.

View raw message