moqui / moqui-framework

Use Moqui Framework to build enterprise applications based on Java. It includes tools for databases (relational, graph, document), local and web services, web and other UI with screens and forms, security, file/resource access, scripts, templates, l10n, caching, logging, search, rules, workflow, multi-instance, and integration.
http://www.moqui.org
Other
284 stars 204 forks source link

entity-find with pagination throw error when offset-style="cursor" #455

Open chunlinyao opened 3 years ago

chunlinyao commented 3 years ago

With cursor offset-style, rs.absolute be called, which throw Exception because resultSetType= FORWARD_ONLY. should we set resultSetType in org.moqui.impl.entity.EntityFindBase#iteratorExtended? Or should we set it conditionaly for offset-style="cursor" only?

jonesde commented 3 years ago

Which database and JDBC driver are you using? Are you using the cursor offset-style because it doesn't support the others and/or doesn't support any sort of offset and limit?

We could try a fix for this by overriding the resultSetType with offset-style=cursor. The place to do this would be in EntityFindBase.groovy, if you search for 'resultSetType' in that file you'll see a couple of places that already have overrides to defaults, and for find one a hard override to use type forward only and concur read only.

Part of the reason for only hard setting resultSetType when offset-style=cursor is that other databases are intolerant in the other direction and there will be errors in various cases unless forward only is used.

Another option might be to adjust the iteration logic to not use absolute. If it is iterating forward only anyway then maybe the database and JDBC driver you're using will be happier with a calculated relative position advance instead of using absolute.

chunlinyao commented 3 years ago

I am accessing some tables in an old mssql server 2000, which not support offset. The jdbc driver is com.microsoft:sqljdbc4:3.0

David E. Jones notifications@github.com 于 2020年12月3日周四 上午3:57写道:

Which database and JDBC driver are you using? Are you using the cursor offset-style because it doesn't support the others and/or doesn't support any sort of offset and limit?

We could try a fix for this by overriding the resultSetType with offset-style=cursor. The place to do this would be in EntityFindBase.groovy, if you search for 'resultSetType' in that file you'll see a couple of places that already have overrides to defaults, and for find one a hard override to use type forward only and concur read only.

Part of the reason for only hard setting resultSetType when offset-style=cursor is that other databases are intolerant in the other direction and there will be errors in various cases unless forward only is used.

Another option might be to adjust the iteration logic to not use absolute. If it is iterating forward only anyway then maybe the database and JDBC driver you're using will be happier with a calculated relative position advance instead of using absolute.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/moqui/moqui-framework/issues/455#issuecomment-737460238, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEJN3L723R4LMIEW6F7J3SS2LZBANCNFSM4UKC2MNA .