Bug 1337337 - [GSS] (6.4.z) HHH-10757, HHH-9021 - "select new ..." with NULL CAST fails with QuerySyntaxException: unexpected AST node: NULL
Summary: [GSS] (6.4.z) HHH-10757, HHH-9021 - "select new ..." with NULL CAST fails wit...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.4.6
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: CR1
: EAP 6.4.11
Assignee: Gail Badner
QA Contact: Martin Simka
URL:
Whiteboard:
Depends On:
Blocks: 1351756 1326118 eap6410-payload
TreeView+ depends on / blocked
 
Reported: 2016-05-18 21:38 UTC by Stephen Fikes
Modified: 2019-11-14 08:05 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1351756 (view as bug list)
Environment:
Last Closed: 2017-01-17 12:55:26 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBEAP-4614 0 Major Verified [GSS] (7.0.z) HHH-10757 HHH-9021 : "select new ..." with CAST( NULL AS ...) fails with QuerySyntaxException: unexpected ... 2017-03-22 14:33:40 UTC

Description Stephen Fikes 2016-05-18 21:38:05 UTC
Description of problem:
https://hibernate.atlassian.net/browse/HHH-10757
https://issues.jboss.org/browse/JBEAP-4614

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 JBoss JIRA Server 2016-05-27 20:28:40 UTC
Gail Badner <gbadner> updated the status of jira JBEAP-4614 to Coding In Progress

Comment 2 Gail Badner 2016-05-27 23:03:48 UTC
I've created a pull request upstream and am waiting for it to be reviewed:
https://github.com/hibernate/hibernate-orm/pull/1388

Comment 5 Gail Badner 2016-06-02 00:47:43 UTC
Pushed upstream to 4.2 branch: https://github.com/hibernate/hibernate-orm/commit/5e8124bf8f8c5d73dbabe2fd1f94ede6a50050e7

Comment 6 Gail Badner 2016-07-08 02:02:00 UTC
HHH-10757 fixes null projections using HQL only. It does not fix null projections using JPA queries.

HHH-9021 fixes null literal projections using JPA queries; integer literals are also fixed for JPA CriteriaQuery

In 5.0 HHH-9021 also fixes HHH-10729 and HHH-10861. That is not the case for 4.2 branch. null literals (HHH-10861) and boolean literals (HHH-10729) remain broken using JPA CriteriaQuery.

Comment 8 JBoss JIRA Server 2016-07-14 09:43:14 UTC
Bartosz Baranowski <bbaranow> updated the status of jira JBEAP-4614 to Resolved

Comment 9 Jiří Bílek 2016-08-10 10:55:36 UTC
Verified with EAP 6.4.10.CP.CR1

Comment 10 Jiří Bílek 2016-08-30 09:06:26 UTC
Fix for HHH-10757 works well, but fix for HHH-9021 works only for mysql, postgresql and postgreplus.
Issue still founded with db2, oracle11, oracle12c, mssql and sybase.

Comment 11 Petr Penicka 2016-08-30 09:20:58 UTC
Reopening since the fix is only partial (see comment 10). Partial fix can go into 6.4.10, no need to respin. Full fix should go into next CP.

Comment 12 Petr Penicka 2016-08-30 09:41:29 UTC
Resetting acks, moving to 6.4.11 target release and payload.

Comment 14 Jan Martiska 2016-08-30 12:01:40 UTC
I've been digging into this. Regarding HHH-9021, there are two failing tests:

CriteriaLiteralInSelectExpressionTest.testStringLiteral2 
- fails on db2, oracle, mssql and sybase 
- I think these databases don't support queries like [select 1=2 from ....] and the test should be skipped on these databases. The generated query looks correct to me, it's just not supported by all DBs.

QueryWithLiteralsInSelectExpressionTest.testSelectNullLiterals
- this fails on MySQL and MariaDB
- HQL snippet "SELECT cast(null as char)" is transformed to SQL snippet "select cast(null as bit)", which is not accepted by MySQL and MariaDB
- if it were transformed to "select cast(null as CHAR)" it would work

So I would say that in the first case it's only a problem of the test,  the second case looks like a bit of a bug to me.
Gail, can you please confirm my theory?

Comment 17 Gail Badner 2016-08-31 07:51:48 UTC
I've created a jira issue to skip CriteriaLiteralInSelectExpressionTest.testStringLiteral2  for Oracle, DB2, SQL Server, and Sybase dialects: https://hibernate.atlassian.net/browse/HHH-11072

Regarding QueryWithLiteralsInSelectExpressionTest.testSelectNullLiterals, the query that fails on MySQL starts with "SELECT cast(null as boolean)", which gets transformed to ""select cast(null as bit)"; "SELECT cast(null as char)" actually works. I created a jira for this issue as well: https://hibernate.atlassian.net/browse/HHH-11073

Both issues have been fixed in Hibernate ORM master, 5.1, 5.0 and 4.2 branches.

@jmartisk, please create JBEAP and BZ issues for HHH-11072 and HHH-11073.

Comment 18 Martin Simka 2016-08-31 10:03:34 UTC
Jan is OOO today. I created 

EAP 7.1 issues: 
https://issues.jboss.org/browse/JBEAP-5813
https://issues.jboss.org/browse/JBEAP-5815

EAP 7.0.z issues:
https://issues.jboss.org/browse/JBEAP-5816
https://issues.jboss.org/browse/JBEAP-5817

EAP 6.4.z issues:
https://bugzilla.redhat.com/show_bug.cgi?id=1371863
https://bugzilla.redhat.com/show_bug.cgi?id=1371864

Can someone please check created issues whether they have all attributes required for CP stream (fix version, acks, ... ) ?

Also I think this BZ can be switched to VERIFIED, fixes have own BZs.

Comment 19 Jiří Bílek 2016-09-05 10:37:56 UTC
Verified with EAP 6.4.10.CP.CR2

Comment 21 Petr Penicka 2017-01-17 12:55:26 UTC
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.


Note You need to log in before you can comment on or make changes to this bug.