[Hibernate-JIRA] Updated: (HHH-892) HQL parser does not resolve alias in ORDER BY clause
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-892?page=co... ]
Gail Badner updated HHH-892:
----------------------------
Attachment: HHH-892.patch
I'm attaching a patch of my first attempt at a fix.
It replaces aliases for HQL select expressions that are used in ORDER BY clauses with the actual SQL column aliases that Hibernate generated.
For example:
HQL: select c.name as myname FROM org.hibernate.test.jpa.Item c ORDER BY myname
results in Hibernate generating:
SQL: select item0_.NAME as col_0_0_ from EJB3_ITEM item0_ order by col_0_0_
>From discussions with Steve Ebersole, I understand that this may not work for all dialects, so something will need to be added to Dialect to indicate how aliases for HQL select expressions should be replaced.
The other possibilities are to replace the alias for an HQL select expression with:
1) the position(s) of the SQL select expressions that correspond with the HQL select expression alias (e.g., select item0_.NAME as col_0_0_ from EJB3_ITEM item0_ order by 1)
2) the actual SQL columns that correspond to the aliased HQL select expression (this probably will not work for all dialects).
The fix in the patch will not work reliably if a position, rather than an alias is used in the HQL ORDER BY clause. That's because the position in the HQL will simply "fall through" to the generated SQL. Since HQL select expressions can result in multiple SQL expressions, the position of an HQL expression could translate to a different (or multiple) positions in the generated SQL.
Does anyone know about a dialect that should use positions instead of column aliases in the ORDER BY clause?
Any help working out these details would be most appreciated. I'd really like to get this fixed as well.
Thanks,
Gail
> HQL parser does not resolve alias in ORDER BY clause
> -----------------------------------------------------
>
> Key: HHH-892
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-892
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.5.4, 3.6.0.Beta1
> Environment: Hibernate 3.0.5, MySQL, Tomcat
> Reporter: Guido Laures
> Assignee: Gail Badner
> Fix For: 3.5.x, 3.6.x
>
> Attachments: HHH-892.patch, HibernateHavingAliasTest.java
>
>
> When using an alias for an ORDER BY clause this is not always correctly resolved. Example:
> SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY mySum
> does not work because "mySum" is not resolved in the ORDER BY clause which results in an exception telling that mySum is an unknown column.
> Workaround (not to say "hack") is using:
> SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY col_0_0_
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 5 months
[Hibernate-JIRA] Updated: (HHH-1570) criteria-api: filtering by key-many-to-one causes invalid sql
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1570?page=c... ]
Gail Badner updated HHH-1570:
-----------------------------
Affects Version/s: (was: 3.1.2)
3.5.3
3.6.0.Beta1
> criteria-api: filtering by key-many-to-one causes invalid sql
> -------------------------------------------------------------
>
> Key: HHH-1570
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1570
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.5.3, 3.6.0.Beta1
> Reporter: Joris Verschoor
> Attachments: HHH-1570-fix.patch, HHH-1570-it.patch, hibernate.patch
>
>
> We have a class Price that has a composite-id using a couple of key-properties and some key-many-to-ones)
> One of those is "transportation", which has a many-to-one to transportationType
> When we query using: criteria.add(Expression.eq("price.transportation.transportationType.id", transId);, we get an invalid SQL statement: The table of transportation was not selected.
> I will try to make a testcase today or tomorrow, depending on my schedule.. Things will be more clear by then...
> We have created a work-around, by mapping the transportationID twice: once in key-property, and once as a many-to-one. (instead of one key-many-to-one)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-5401) Update to HHH-5381 HSQLDB new dialect (Fred Toussi)
by Fred Toussi (JIRA)
Update to HHH-5381 HSQLDB new dialect (Fred Toussi)
----------------------------------------------------
Key: HHH-5401
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5401
Project: Hibernate Core
Issue Type: Patch
Environment: HSQLDB Hibernate 3.5.x
Reporter: Fred Toussi
Attachments: HSQLDialect.diff
Issue opened as advised by Steve.
An updated version of HHH-581 that reflects some user feedback with existing databases upgraded to 2.0 and new databases.
In this version BOOLEAN is included in the list of types and the literal values for BOOLEAN are defined as "true" or "false" instead of "1" or "0".
Both v. 1.8.x and 2.0 support BOOLEAN (with true and false). In 1.8.x BIT is a synonym for BOOLEAN. In 2.0, BIT is a separate type representing a bit map which can have 0 or 1. As BOOLEAN is the prefered type in terms of storage requirements and usage in queries, it is better if this is used directly.
I did not make this change initially as I was concerned about possible effects with existing databases. It now seems the change has no side effects and actually results in better SQL conformance.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 5 months