-->
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.  [ 5 posts ] 
Author Message
 Post subject: Paging with Sybase Anywhere
PostPosted: Wed May 19, 2004 5:46 pm 
Newbie

Joined: Sun May 09, 2004 10:34 pm
Posts: 16
I have several questions involving paging with Sybase Anywhere. I believe I've read all the posts concerning paging with Hibernate, but I haven't run across any that pertain to Sybase Anywhere specifically.

My first question concerns the SybaseAnywhereDialect with Sybase 9.0. A few examples I've coded seem to work fine, however once I attempted to implement a paging example using Query.setMaxResults() and Query.setFirstResult() I received an exception:

Code:
FINE: SQL Exception
java.sql.SQLException: JZ0BT: The absolute(int) method is not supported for ResultSets of type TYPE_FORWARD_ONLY.
   at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:468)
   at com.sybase.jdbc2.jdbc.SybResultSet.checkForScrollability(SybResultSet.java:1612)
   at com.sybase.jdbc2.jdbc.SybResultSet.absolute(SybResultSet.java:648)


This resulted from the following calls with the Query class:

Code:
String queryString = "select reference from com.fedex.fsme.model.Reference reference order by reference.name";
         Query query = session.createQuery(queryString);
         query.setMaxResults(size);
         query.setFirstResult((page - 1) * size);

         return query.list();



If the SybaseAnywhereDialect is attempting to use absolute with the TYPE_FORWARD_ONLY result set type, I wouldn't imagine this works
with ASA version 8 either. Is this correct?

My second question is, if it is concluded that this is a bug in Hibernate, is there another method for performing paging?


My third question is, since Sybase 9 has introduced the ability to select with "START AT", are there plans to create a SybaseAnywhere9Dialect that takes advantage of this? I'm assuming this is more efficient than retrieving a FORWARD_ONLY result set and attempting to advance to the
specified offset.

I'll probably have more questions after Gavin answers these :)

Derek Greer


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 6:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
There are no differences between the Sybase dialects considering setMaxResult/setFirstResults. I'd rather suppose this is a driver problem. Have you tried to set hibernate.jdbc.use_scrollable_resultset=false?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 10:23 am 
Newbie

Joined: Sun May 09, 2004 10:34 pm
Posts: 16
I haven't tried that yet, but I assumed it was already set to false for several reasons. One, I assumed that the developer of that Dialect was aware of the Sybase driver's problems with supporting scrollable cursors (i.e. it has to store the retrieved records in memory causing out of memory errors to occur for large result sets) and therefore would have set this to false. Second, since the exception I got indicates that the result set type is being set to TYPE_FORWARD_ONLY rather than TYPE_SCROLL_INSENSITIVE, I assumed this was already set to false. I'll give it a try anyway and post my results.

Concerning differences between the Sybase dialects, I didn't suggest that there were any differences. My question is whether there will be a new Dialect created to take advantage of the addition of "START AT' with ASA version 9.

Have you (or any other reader's of this post) successfully implemented paging using the setMaxResults() and setFirstResult() methods with Sybase 8 or 9? Of course I'm more interested in version 9 results, but if you have implemented it successfully in version 8 then that might indicate something is either incorrect with my settings/implementation or with the compatiability of the SybaseAnywhereDialect with version 9.

Derek


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 11:04 am 
Newbie

Joined: Sun May 09, 2004 10:34 pm
Posts: 16
I tried setting hibernate.jdbc.use_scrollable_resultset to false and it now works. Of course, this leaves me with the question of how the Dialect was attempting to accomplish using a scrollable resultset if the result set was being set to TYPE_FORWARD_ONLY (which wouldn't have allowed this even if the code weren't attempting to use the absolute() method). Even though setting this to false causes it to work, the Sybase JConnect 5.x driver does support scrollable resultsets (just very inefficiently), therefore setting hibernate.jdbc.use_scrollable_resultset to true shouldn't cause exceptions to be thrown. Therefore, there still seems to be a bug.

Given these findings, I'll refine my first question. Since Hibernate throws exceptions when using the scrollable resultset feature of ASA version 9, does it have the same limitations with version 8?

These results seem to answer my second question, but I'm still interested in getting an answer to the third.


I would also like to find out exactly how this paging is being accomplished short of diving into the code myself. Is the dialect now selecting the query and manually advancing from the beginning to the given offset?

Thanks.

Derek


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 1:22 pm 
Newbie

Joined: Sun May 09, 2004 10:34 pm
Posts: 16
Is anyone out there? I know no one is under any obligation to answer these questions, but this is the only avenue I'm aware of right now to ask the Hibernate community questions such as these. A user's mailing list would probably be more benificial for getting questions answered, since more people are likely to read the posts.

Unless one of the developers can answer the questions concerning Sybase Anywhere 9, I guess I'll just have to keep checking back with Hibernate to see if a new Dialect is created to take advantage of the new Sybase features.

As a generic Sybase question, I am curious whether it is more efficient to use a select with START AT verses using a forward only result set and moving to the offset with resultSet.next() each time (as I suppose the SybaseAnywhereDialect is doing). If the new START AT does the same steps, but just offers the convenience of not having to do it yourself with JDBC then I guess there would be no need for a SybaseAnywhere9Dialect (at least for this new feature).

Derek[/b]


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

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.