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

Richard Zowalla resolved OPENJPA-212.
-------------------------------------
    Resolution: Fixed

Already fixed in an earlier release (covered by 
TestJPQLMultiSelectTypedResults); closing.

> Constructor expression permits no other expressions in SELECT clause
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-212
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-212
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: query
>    Affects Versions: 0.9.7
>            Reporter: Jacek Laskowski
>            Priority: Major
>
> It seems that it's impossible to run a query with constructor expression 
> beside other expressions in SELECT clause. Take a look at the following test 
> that finishes with ClassCastException when the first element of resultQuery 
> is returned (the 2nd line of the snippet).  Am I doing something plain wrong?
> It doesn't work with Hibernate EntityManager 3.3.1, either yet TopLink 
> Essentials 2.0 BUILD 40 runs fine.
>   Query query = em.createQuery("SELECT NEW 
> pl.jaceklaskowski.jpa.PewnaKlasa(p.nazwa, o.imie, o.nazwisko, o.numer), o, 
> p.nazwa FROM Projekt p JOIN p.chair o");
>   List<Object[]> resultQuery = query.getResultList();
>   final Object[] firstElementInQueryResult = resultQuery.get(0);
>   assert firstElementInQueryResult.length == 3;
>   final Object firstElement = resultQuery.get(0)[0];
>   assert firstElement instanceof PewnaKlasa;
>   final Object secondElement = resultQuery.get(0)[1];
>   assert secondElement instanceof Osoba;
>   final Object thirdElement = resultQuery.get(0)[2];
>   assert thirdElement instanceof String;
> The exception is as follows (the line number is different though as the test 
> above is incomplete - no class, imports and alike are shown):
> java.lang.ClassCastException: pl.jaceklaskowski.jpa.PewnaKlasa
>         at 
> pl.jaceklaskowski.jpa.OpenJPATest.testConstructorExpr(OpenJPATest.java:19)



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to