[Hibernate-JIRA] Created: (HHH-3344) DB2Dialect.getLimitString doesn't work for some queries
by Damon Horrell (JIRA)
DB2Dialect.getLimitString doesn't work for some queries
-------------------------------------------------------
Key: HHH-3344
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3344
Project: Hibernate3
Issue Type: Bug
Reporter: Damon Horrell
Priority: Minor
If a query uses * but doesn't use a table alias then the modified query created by DB2Dialect.getLimitString is invalid.
e.g.
select * from mytable
becomes
select * from ( select rownumber() over() as rownumber_, * from mytable ) as temp_ where rownumber_ <= ?
which causes
DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: *;ver() as rownumber_,;<select_sublist>
I have worked around this for my project by extending DB2Dialect with:
public String getLimitString(String sql, boolean hasOffset) {
return "select * from ( select rownumber() over() as rownumber_, original_query.* from (" + sql
+ ") original_query ) as temp_ where rownumber_ <= ?";
}
This code will need extending to handle the hasOffset case etc.
Real code probably won't be using select * anyway so this probably isn't a big problem. My example allows the user to enter a custom query so I have to handle this situation.
--
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
12 years, 11 months
[Hibernate-JIRA] Created: (HHH-4943) ilike support is incomplete
by James Nobis (JIRA)
ilike support is incomplete
---------------------------
Key: HHH-4943
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4943
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: 3.3.2GA
MySQL/PostgreSQL
Reporter: James Nobis
ILIKE is currently supported for PostgreSQL in:
hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/criterion/IlikeExpression.java:
if ( dialect instanceof PostgreSQLDialect ) {
return columns[0] + " ilike ?";
}
else {
return dialect.getLowercaseFunction() + '(' + columns[0] + ") like ?";
}
//TODO: get SQL rendering out of this package!
1) This should be in the Dialect
2) PostgreSQL isn't the only DB with ILIKE
3) using instanceof for this is just sloppy
4) this implementation using getLowercaseFunction works with MySQL but fails with DBs like Firebird
--
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
12 years, 11 months