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


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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to