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 2020/07/13 09:13:28 UTC

[GitHub] [shardingsphere] vther opened a new issue #6332: JPA [count distinct] cause [javax.persistence.NoResultException: No entity found for query]

vther opened a new issue #6332:
URL: https://github.com/apache/shardingsphere/issues/6332


   ## Bug Report
   
   ```java
           Object singleResult = entityManager
               .createQuery("SELECT count (distinct i.orderItemId) from OrderItemEntity i where i.orderId = :orderId")
               .setParameter("orderId", 11111111111111111L) 
               .getSingleResult();
   ```
   when use `count distinct` and `entitymanager#getSingleResult()` cause javax.persistence.NoResultException
   
   ### Which version of ShardingSphere did you use?
   
   [4.0.1 , 4.1.1] the bug remains
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
    ShardingSphere-JDBC
   
   ### Expected behavior
   
   ### Actual behavior
   
   ### Reason analyze (If you can)
   
    Actual SQL lack of count ,is it intentional or a bug?
   
   ```
   [INFO ] 2020-07-13 17:01:36,835 --main-- [ShardingSphere-SQL] Logic SQL: select count(distinct orderiteme0_.order_item_id) as col_0_0_ from t_order_item orderiteme0_ where orderiteme0_.order_id=? 
   [INFO ] 2020-07-13 17:01:36,835 --main-- [ShardingSphere-SQL] SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@6fbf5db2, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@509a6095), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@509a6095, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=60, distinctRow=false, projections=[AggregationProjection(type=COUNT, innerExpression=(distinct orderiteme0_.order_item_id), alias=Optional[col_0_0_], derivedAggregationProjections=[], index=-1)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@57cabdc3, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@75bd28d, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@129c4d19, containsSubquery=false) 
   [INFO ] 2020-07-13 17:01:36,835 --main-- [ShardingSphere-SQL] Actual SQL: demo_ds_0 ::: select DISTINCT orderiteme0_.order_item_id as col_0_0_ from t_order_item orderiteme0_ where orderiteme0_.order_id=? ::: [11111111111111111] 
   [INFO ] 2020-07-13 17:01:36,835 --main-- [ShardingSphere-SQL] Actual SQL: demo_ds_1 ::: select DISTINCT orderiteme0_.order_item_id as col_0_0_ from t_order_item orderiteme0_ where orderiteme0_.order_id=? ::: [11111111111111111] 
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
    .setParameter("orderId", 11111111111111111L) 
   this step is necessary 
   
   ### Example codes for reproduce this issue (such as a github link).
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking commented on issue #6332: JPA [count distinct] cause [javax.persistence.NoResultException: No entity found for query]

Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #6332:
URL: https://github.com/apache/shardingsphere/issues/6332#issuecomment-657460038


   It has been fixed in https://github.com/apache/shardingsphere/pull/6118 for master branch 5.0.0-RC1


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] vther commented on issue #6332: JPA [count distinct] cause [javax.persistence.NoResultException: No entity found for query]

Posted by GitBox <gi...@apache.org>.
vther commented on issue #6332:
URL: https://github.com/apache/shardingsphere/issues/6332#issuecomment-657481965


   > It has been fixed in #6118 for master branch 5.0.0-RC1
   
   @kimmking 
   Will this fix merge into 4.x ?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking closed issue #6332: JPA [count distinct] cause [javax.persistence.NoResultException: No entity found for query]

Posted by GitBox <gi...@apache.org>.
kimmking closed issue #6332:
URL: https://github.com/apache/shardingsphere/issues/6332


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org