-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Issue with SQLServerDialect and Query.setMaxResults()
PostPosted: Fri Apr 08, 2005 1:23 pm 
Expert
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.