question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sharding-jdbc: Oracle pagination query error

See original GitHub issue

version

<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>5.1.1</version>

testcase

def "testOraclePagination"() {

        when: "pagination case 1"
        def pagination_sql2 = """
    select * from (
    select t1."num",rownum as "rownum_" from(
        select 'a'  as "num" from dual)t1)
    where "rownum_" >? and "rownum_"< ?
"""

        try (def connection = sqlSessionFactory.openSession().getConnection()) {
            connection.prepareStatement(pagination_sql2)
        }
        then:
        noExceptionThrown()

        when: "pagination case 2"
        def pagination_sql3 = """
    select t2."num",t2,"rownum_" from (
    select t1."num",rownum as "rownum_" from(
        select 'a'  as "num" from dual)t1)t2
    where t2."rownum_" > ? and t2."rownum_" <= (?+?)
"""

        try (def connection = sqlSessionFactory.openSession().getConnection()) {

            connection.prepareStatement(pagination_sql3)
        }
        then:
        noExceptionThrown()


        when: "pagination case 3"
        def pagination_sql4 = """
    select * from (
    select t1."num",rownum as "rownum_" from(
        select 'a'  as "num" from dual)t1)
    where t2."rownum_" > ? and t2."rownum_" <= (?+?)
"""

        try (def connection = sqlSessionFactory.openSession().getConnection()) {

            connection.prepareStatement(pagination_sql4)
        }
        then:
        noExceptionThrown()
    }

pagination case 3 throw exception

Caused by: java.lang.ClassCastException: class org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.complex.CommonExpressionSegment cannot be cast to class org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment (org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.complex.CommonExpressionSegment and org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment are in unnamed module of loader 'app')
	at org.apache.shardingsphere.infra.binder.segment.select.pagination.engine.RowNumberPaginationContextEngine.createRowNumberValueSegment(RowNumberPaginationContextEngine.java:142)
	at org.apache.shardingsphere.infra.binder.segment.select.pagination.engine.RowNumberPaginationContextEngine.createPaginationWithRowNumber(RowNumberPaginationContextEngine.java:129)
	at org.apache.shardingsphere.infra.binder.segment.select.pagination.engine.RowNumberPaginationContextEngine.createPaginationContext(RowNumberPaginationContextEngine.java:67)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
github-actions[bot]commented, Oct 8, 2022

Hello , this issue has not received a reply for several days. This issue is supposed to be closed.

0reactions
pcyancommented, Oct 23, 2022

fixed in ShardingSphere 5.2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

JPA and Oracle DB: Distinct query with pagination leads to ...
Is there a solution for oracle to get the distinct running together with the pagination? EDIT. So it seems like oracle fails with...
Read more >
Pagination query and optimization - Ask TOM
Hi Tom, I've been reading through a few posts regarding pagination. I'm using the following query template in my application, ...
Read more >
pagination problem — oracle-tech
But the performance of all my pages is same(very slow and poor). I am refreshing the page and performing the query once again....
Read more >
On Top-n and Pagination Queries - Oracle Blogs
in order to get rows n through m from "your query." As always, there is more than one way to do things in...
Read more >
What is efficient way to paginate on the large table? - Ask TOM
Also, when the offset is big then Oracle does a full table scan. select /*+ gather_plan_statistics */ * from t order by pk...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found