Hibernate version: 3.3.1 GA
MySQL Version: 5.1.34-community
JDBC Connector: mysql-connector-java-5.1.7
Dialect: org.hibernate.dialect.MySQL5InnoDBDialect
I have a HQL query that looks like this:
Code:
select new list(ca.receivedTransactions, ca.sentTransactions) from CustomerAccount ca where ca.customer.customerId = :customerId
Where receivedTransactions and sentTransactions both are of type A or B both inheriting (EJB3 single-table style) from Transaction.
CustomerAccount is inheriting from TransactionAgent. (This should explain the quirks of the SQL below)
So I'm hoping for the list returned to contain objects of type Transaction.
However, as this HQL query is executed, it's generating the following SQL:
Code:
select . as col_0_0_, . as col_1_0_ from TransactionAgent customerac0_ inner join Transaction receivedtr1_ on customerac0_.accountId=receivedtr1_.receiver inner join Transaction senttransa2_ on customerac0_.accountId=senttransa2_.sender where customerac0_.transaction_agent_type='CustomerAccount' and customerac0_.phoneNo=?
Which causes an exception:
19:24:50,250 WARN [JDBCExceptionReporter] SQL Error: 1064, SQLState: 42000
19:24:50,250 ERROR [JDBCExceptionReporter] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as col_0_0_, . as col_1_0_ from TransactionAgent customerac0_ inner join Transac' at line 1
Has anyone seen this issue with the "new list" clause in selects? Is it a known issue? I've tried looking around the JIRA db but haven't really found anything useful... Any ideas of work-arounds?
Using only "select ca.receivedTransactions, ca.sentTransactions ..." works, but it (as expected) returns Object[] which is not the behaviour I'm looking for.