You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/12/27 04:49:27 UTC
[GitHub] [shardingsphere] agoodcoolman opened a new issue #14336: java.lang.String cannot be cast to java.lang.Integer
agoodcoolman opened a new issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336
## Bug Report
**For English only**, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
- Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will **close it**.
Please answer these questions before submitting your issue. Thanks!
### Which version of ShardingSphere did you use?
sharding-jdbc- 5.0.0 databaseļ¼ postsql
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy
### Expected behavior
### Actual behavior
### Reason analyze (If you can)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
table csvone and table csvtwo ,not exist sharding column ,it's a normal small table.
i have searched github issurs, someone tell it's fixed,but i cann't run it.
select name, idcard from ( select idcard, name from csvone where name like '%%' union select idcard, name from csvtwo where name like '%%')
### Example codes for reproduce this issue (such as a github link).
`Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at org.apache.shardingsphere.infra.binder.segment.select.pagination.PaginationContext.getValue(PaginationContext.java:57)
at org.apache.shardingsphere.infra.binder.segment.select.pagination.PaginationContext.<init>(PaginationContext.java:51)
at org.apache.shardingsphere.infra.binder.segment.select.pagination.engine.LimitPaginationContextEngine.createPaginationContext(LimitPaginationContextEngine.java:38)
at org.apache.shardingsphere.infra.binder.segment.select.pagination.engine.PaginationContextEngine.createPaginationContext(PaginationContextEngine.java:57)
at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.<init>(SelectStatementContext.java:91)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.getDMLStatementContext(SQLStatementContextFactory.java:127)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:110)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createLogicSQL(ShardingSpherePreparedStatement.java:385)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:375)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeQuery(ShardingSpherePreparedStatement.java:180)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:57)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2297)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2050)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2012)
at org.hibernate.loader.Loader.doQuery(Loader.java:948)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349)
at org.hibernate.loader.Loader.doList(Loader.java:2843)
at org.hibernate.loader.Loader.doList(Loader.java:2825)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2657)
at org.hibernate.loader.Loader.list(Loader.java:2652)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338)
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2141)
at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1169)
at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:176)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1604)
at org.hibernate.query.Query.getResultList(Query.java:165)
at org.springframework.data.jpa.repository.query.JpaQueryExecution$PagedExecution.doExecute(JpaQueryExecution.java:177)
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:155)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:143)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:145)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
at com.sun.proxy.$Proxy235.queryAllByYear(Unknown Source)
at cn.whmf.wcbigdataweb.action.SearchAction.findALLJzqk(SearchAction.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1063)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
... 50 common frames omitted`
### Error code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman edited a comment on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman edited a comment on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001334206
i don't know how to fix it.
```
public PaginationContext(final PaginationValueSegment offsetSegment, final PaginationValueSegment rowCountSegment, final List<Object> parameters) {
hasPagination = null != offsetSegment || null != rowCountSegment;
this.offsetSegment = offsetSegment;
this.rowCountSegment = rowCountSegment;
actualOffset = null == offsetSegment ? 0L : getValue(offsetSegment, parameters);
actualRowCount = null == rowCountSegment ? null : getValue(rowCountSegment, parameters);
}
```
>
> private long getValue(final PaginationValueSegment paginationValueSegment, final List<Object> parameters) {
> if (paginationValueSegment instanceof ParameterMarkerPaginationValueSegment) {
> Object obj = null == parameters || parameters.isEmpty() ? 0L : parameters.get(((ParameterMarkerPaginationValueSegment) paginationValueSegment).getParameterIndex());
> return obj instanceof Long ? (long) obj : (int) obj;
> } else {
> return ((NumberLiteralPaginationValueSegment) paginationValueSegment).getValue();
> }
> }
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman closed issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman closed issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman edited a comment on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman edited a comment on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001334206
i don't know how to fix it.
```
public PaginationContext(final PaginationValueSegment offsetSegment, final PaginationValueSegment rowCountSegment, final List<Object> parameters) {
hasPagination = null != offsetSegment || null != rowCountSegment;
this.offsetSegment = offsetSegment;
this.rowCountSegment = rowCountSegment;
actualOffset = null == offsetSegment ? 0L : getValue(offsetSegment, parameters);
actualRowCount = null == rowCountSegment ? null : getValue(rowCountSegment, parameters);
}
```
>
> private long getValue(final PaginationValueSegment paginationValueSegment, final List<Object> parameters) {
> if (paginationValueSegment instanceof ParameterMarkerPaginationValueSegment) {
> Object obj = null == parameters || parameters.isEmpty() ? 0L : parameters.get(((ParameterMarkerPaginationValueSegment) paginationValueSegment).getParameterIndex());
> // this LINE
> return obj instanceof Long ? (long) obj : (int) obj;
> } else {
>
> return ((NumberLiteralPaginationValueSegment) paginationValueSegment).getValue();
> }
> }
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman commented on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman commented on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001334206
i don't know how to fix it.
> public PaginationContext(final PaginationValueSegment offsetSegment, final PaginationValueSegment rowCountSegment, final List<Object> parameters) {
> hasPagination = null != offsetSegment || null != rowCountSegment;
> this.offsetSegment = offsetSegment;
> this.rowCountSegment = rowCountSegment;
> actualOffset = null == offsetSegment ? 0L : getValue(offsetSegment, parameters);
> actualRowCount = null == rowCountSegment ? null : getValue(rowCountSegment, parameters);
> }
>
> private long getValue(final PaginationValueSegment paginationValueSegment, final List<Object> parameters) {
> if (paginationValueSegment instanceof ParameterMarkerPaginationValueSegment) {
> Object obj = null == parameters || parameters.isEmpty() ? 0L : parameters.get(((ParameterMarkerPaginationValueSegment) paginationValueSegment).getParameterIndex());
> return obj instanceof Long ? (long) obj : (int) obj;
> } else {
> return ((NumberLiteralPaginationValueSegment) paginationValueSegment).getValue();
> }
> }
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman edited a comment on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman edited a comment on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001900287
this bug havd fixed in lastest version (5.0.1)
[download lastest version](https://github.com/apache/shardingsphere#nightly-builds)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman commented on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman commented on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001900287
this bug havd fixed in lastest version (5.0.1)
[used thid lastest version](https://github.com/apache/shardingsphere#nightly-builds)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman edited a comment on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman edited a comment on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001347254
```
Pageable pageable = PageRequest.of(1, 12);
Page<Csvjyjz> jiuZhuBeans = csvjyjzDAO.queryAllByYear( String.valueOf(year), StringUtils.isEmpty(name)? null: name,StringUtils.isEmpty(idcard)? null: idcard,pageable);
```
```
@Query(value = "select id, name, idcard, '' as address, '' as school from (" +
"select id, name, idcard from csvone where CASE WHEN COALESCE(:name,'1') = '1' THEN 1=1 ELSE name like :name% END and CASE WHEN COALESCE(:idcard,'1') = '1' THEN 1=1 ELSE idcard like :idcard% END " +
" union " +
" select id, name, idcard from csvtwo where CASE WHEN COALESCE(:name1,'1') THEN 1=1 ELSE name like :name% END and CASE WHEN COALESCE(:idcard,'1') = '1' THEN 1=1 ELSE idcard like :idcard% END " +
") re"
,nativeQuery = true)
Page<Csv> queryAllByYear (Pageable Pageable, @Param("year")String year, @Param("name")String name, @Param("idcard")String idcard,
@Param("year1")String year1, @Param("name1")String name1, @Param("idcard1")String idcard1);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman commented on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman commented on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001347254
```
Pageable pageable = PageRequest.of(1, 12);
Page<Csvjyjz> jiuZhuBeans = csvjyjzDAO.queryAllByYear( String.valueOf(year), StringUtils.isEmpty(name)? null: name,StringUtils.isEmpty(idcard)? null: idcard,pageable);
```
@Query(value = "select id, name, idcard, '' as address, '' as school from (" +
"select id, name, idcard from csvone where CASE WHEN COALESCE(:name,'1') = '1' THEN 1=1 ELSE name like :name% END and CASE WHEN COALESCE(:idcard,'1') = '1' THEN 1=1 ELSE idcard like :idcard% END " +
" union " +
" select id, name, idcard from csvtwo where CASE WHEN COALESCE(:name1,'1') +
") re"
,nativeQuery = true)
Page<Csv> queryAllByYear (Pageable Pageable, @Param("year")String year, @Param("name")String name, @Param("idcard")String idcard,
@Param("year1")String year1, @Param("name1")String name1, @Param("idcard1")String idcard1);
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman edited a comment on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman edited a comment on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001334206
i don't know how to fix it.
> public PaginationContext(final PaginationValueSegment offsetSegment, final PaginationValueSegment rowCountSegment, >final List<Object> parameters) {
> hasPagination = null != offsetSegment || null != rowCountSegment;
> this.offsetSegment = offsetSegment;
> this.rowCountSegment = rowCountSegment;
> actualOffset = null == offsetSegment ? 0L : getValue(offsetSegment, parameters);
> actualRowCount = null == rowCountSegment ? null : getValue(rowCountSegment, parameters);
> }
>
> private long getValue(final PaginationValueSegment paginationValueSegment, final List<Object> parameters) {
> if (paginationValueSegment instanceof ParameterMarkerPaginationValueSegment) {
> Object obj = null == parameters || parameters.isEmpty() ? 0L : parameters.get(((ParameterMarkerPaginationValueSegment) paginationValueSegment).getParameterIndex());
> return obj instanceof Long ? (long) obj : (int) obj;
> } else {
> return ((NumberLiteralPaginationValueSegment) paginationValueSegment).getValue();
> }
> }
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] agoodcoolman edited a comment on issue #14336: java.lang.String cannot be cast to java.lang.Integer
Posted by GitBox <gi...@apache.org>.
agoodcoolman edited a comment on issue #14336:
URL: https://github.com/apache/shardingsphere/issues/14336#issuecomment-1001347254
```
Pageable pageable = PageRequest.of(1, 12);
Page<Csvjyjz> jiuZhuBeans = csvjyjzDAO.queryAllByYear( String.valueOf(year), StringUtils.isEmpty(name)? null: name,StringUtils.isEmpty(idcard)? null: idcard,pageable);
```
```
@Query(value = "select id, name, idcard, '' as address, '' as school from (" +
"select id, name, idcard from csvone where CASE WHEN COALESCE(:name,'1') = '1' THEN 1=1 ELSE name like :name% END and CASE WHEN COALESCE(:idcard,'1') = '1' THEN 1=1 ELSE idcard like :idcard% END " +
" union " +
" select id, name, idcard from csvtwo where CASE WHEN COALESCE(:name1,'1') +
") re"
,nativeQuery = true)
Page<Csv> queryAllByYear (Pageable Pageable, @Param("year")String year, @Param("name")String name, @Param("idcard")String idcard,
@Param("year1")String year1, @Param("name1")String name1, @Param("idcard1")String idcard1);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org