You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Ognjen Blagojevic <og...@etf.bg.ac.yu> on 2008/08/19 13:36:00 UTC

Selecting multiple objects - bug?

Hi,

When I try to select multiple objects in a query like this one 
(publisher of the magazine can be null - unknown):

SELECT m, p
   FROM Magazine m
   LEFT OUTER JOIN m.idPublisher p
  WHERE ((:useName = false) OR (p.name like :name))

I would expect to get the resultset of pairs (Magazine, Publisher), but 
what OpenJPA 1.1.0 returns is resultset of pairs (Publisher, Publisher).

Did anyone else noticed this behavior, and should I file a bug report?

Is it allowed in JPA spec to select multiple objects?


Regards,
Ognjen

ps. I know I could select just Magazine, and then get Publisher from 
there. The actual query is more complex, this one is just for the 
purpose of showing the bug.

Re: Selecting multiple objects - bug?

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
  Added a test case [1] with revision 687806 following your example --
please verify if this test and its assertions reflect your test conditions.
The test passes on trunk.
  

[1]
http://n2.nabble.com/svn-commit%3A-r687806---in--openjpa-trunk-openjpa-persistence-jdbc-src-test-java-org-apache-openjpa-persistence-jdbc-query%3A-TestMultipleEntityProjection.java-domain-Magazine.java-domain-Publisher.java-tc740712.html


-- 
View this message in context: http://n2.nabble.com/Selecting-multiple-objects---bug--tp732941p740724.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Re: Selecting multiple objects - bug?

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
> So, if there are plans to maintain a 1.1.x branch, tests should be copied
> over there, too.
  The fix [1]  relevant to this issue had been applied to 1.2 branches and
currently there is no plan for backporting it to 1.1.x branches.  


[1] https://issues.apache.org/jira/browse/OPENJPA-209



-- 
View this message in context: http://n2.nabble.com/Selecting-multiple-objects---bug--tp732941p759804.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Re: Selecting multiple objects - bug?

Posted by Ognjen Blagojevic <og...@etf.bg.ac.yu>.
Pinaki Poddar wrote:
> Hi,
>   The result should return (Magazine, Publisher) pairs.
> 
>   Please post 
>   a) the relevant mapping declarations of Magazine and Publisher
>   b) the SQL generated by OpenJPA
> 
>   for further analysis.

It was a bug in 1.1.0. Just tested with 1.2.0 and it works fine.

Output with 1.1.0 (erratic, returns two Publishers in a row)

AB press, AB press,
CD press, AB press,
EF press, AB press,
null, CD press,
null, EF press,
Results: 5


Output with 1.2.0 (as expected, returns Magazine and Publisher):

alpha, AB press,
beta, AB press,
gamma, AB press,
foobar, CD press,
barfoo, EF press,
Results: 5

So, if there are plans to maintain a 1.1.x branch, tests should be 
copied over there, too.

Regards,
Ognjen

Re: Selecting multiple objects - bug?

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
  The result should return (Magazine, Publisher) pairs.

  Please post 
  a) the relevant mapping declarations of Magazine and Publisher
  b) the SQL generated by OpenJPA

  for further analysis.

-- 
View this message in context: http://n2.nabble.com/Selecting-multiple-objects---bug--tp732941p740434.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Re: Selecting multiple objects - bug?

Posted by Ognjen Blagojevic <og...@etf.bg.ac.yu>.
According to JPA spec, this seems to be bug:

"4.8.1 Result Type of the SELECT Clause"

states:

"The type of the query result specified by the SELECT clause of a query 
is an entity abstract schema type, a state-field type, the result of an 
aggregate function, the result of a construction operation, or some 
sequence of these."

Since "m, p" in the given query represents "some sequence of" entities, 
it should be allowed.


Could anyone, please, confirm that this is erratic behavior before I 
raise u bug in JIRA?

Regards,
Ognjen


Ognjen Blagojevic wrote:
> Hi,
> 
> When I try to select multiple objects in a query like this one 
> (publisher of the magazine can be null - unknown):
> 
> SELECT m, p
>   FROM Magazine m
>   LEFT OUTER JOIN m.idPublisher p
>  WHERE ((:useName = false) OR (p.name like :name))
> 
> I would expect to get the resultset of pairs (Magazine, Publisher), but 
> what OpenJPA 1.1.0 returns is resultset of pairs (Publisher, Publisher).
> 
> Did anyone else noticed this behavior, and should I file a bug report?
> 
> Is it allowed in JPA spec to select multiple objects?
> 
> 
> Regards,
> Ognjen
> 
> ps. I know I could select just Magazine, and then get Publisher from 
> there. The actual query is more complex, this one is just for the 
> purpose of showing the bug.
>