Expert |
|
Joined: Mon Feb 14, 2005 12:32 pm Posts: 609 Location: Atlanta, GA - USA
|
I am using Hibernate3 final and I am not posting a lot of code here or the stack trace I received since I've taken the time to find the problem.
In the SQLServerDialect method
static int getAfterSelectInsertPoint(String sql) {
final int selectDistinctIndex = sql.indexOf( "select distinct" );
if ( selectDistinctIndex >= 0 ) {
return selectDistinctIndex + 15;
}
else {
return sql.indexOf( "select" ) + 6;
}
}
the sql.indexOf() methods do not take case into account. When I used this code with a named SQLQuery similar to SELECT {hivTest.*} from HIV_TEST hivTest .....
Then executed it in my code as
Query q = getNamedQuery("myNamedQuery");
q.setMaxResults(10);
result = q.list();
The resulting generated SQL was
SELEC top 10T hivTest.TEST_ID as TEST1_0_, .....
Notice the top 10 was inserted into the word SELECT.
This is easily fixed by changing the case of the word SELECT to select.
|
|