[
https://hibernate.onjira.com/browse/HHH-3307?page=com.atlassian.jira.plug...
]
Robert Rodehorst edited comment on HHH-3307 at 4/6/12 2:35 PM:
---------------------------------------------------------------
Confirmed this issue by modifying HXTT's Microsoft Access dialect with the following
{{transformSelectString}} function:
{code:title=com.hxtt.support.hibernate.HxttAccessDialect.java}
public String transformSelectString(String select) {
select = super.transformSelectString(select);
// Find all joins
int count = 0;
int idx = 0;
String sub = " join ";
while((idx = select.indexOf(sub, idx)) != -1) {
count++;
idx += sub.length();
}
// Remove "outer" keywords and add nested parentheses
if (count > 0) {
select = select.replaceAll(" left outer join ", ") left join
");
select = select.replaceAll(" right outer join ", ") right join
");
select = select.replaceAll(" inner join ", ") inner join
");
select = select.replaceAll(" from ", " from " +
StringHelper.repeat('(', count));
}
return select;
}
{code}
As mentioned in the original report, this works fine for loading Hibernate mappings.
However, executing HQL queries with more than one join results in syntax errors, as the
nested parentheses required for Access queries never get applied.
was (Author: gooberking):
Confirmed this issue by modifying HXTT's Microsoft Access dialect with the
following transformSelectString function:
{code:title=com.hxtt.support.hibernate.HxttAccessDialect.java|borderStyle=solid}
public String transformSelectString(String select) {
select = super.transformSelectString(select);
// Find all joins
int count = 0;
int idx = 0;
String sub = " join ";
while((idx = select.indexOf(sub, idx)) != -1) {
count++;
idx += sub.length();
}
// Remove "outer" keywords and add nested parentheses
if (count > 0) {
select = select.replaceAll(" left outer join ", ") left join
");
select = select.replaceAll(" right outer join ", ") right join
");
select = select.replaceAll(" inner join ", ") inner join
");
select = select.replaceAll(" from ", " from " +
StringHelper.repeat('(', count));
}
return select;
}
{code}
As mentioned in the original report, this works fine for loading Hibernate mappings.
However, executing HQL queries with more than one join results in syntax errors, as the
nested parentheses required for Access queries never get applied.
HQL query translation in real SQL ignores the dialect class
-----------------------------------------------------------
Key: HHH-3307
URL:
https://hibernate.onjira.com/browse/HHH-3307
Project: Hibernate ORM
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Environment: dialect file with special JoinFragment and a
"transformSelectString" step
Reporter: Thomas Schilf
We're using a special dialect class for a database. In the dialect is defined a own
JoinFragment and a "transformSelectString" step.
All workes fine by loading objects over a Criteria class.
The generated SQL string is wrong by using named queries (HQL). The SQL string is in
normal ANSI-SQL.
The SqlGenerator and QueryTranslatorImpl classes from hibernate don't use the dialect
class.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira