gxgmy521 opened a new issue #4256: hintManager.setDatabaseShardingValue do not 
work.
URL: https://github.com/apache/incubator-shardingsphere/issues/4256
 
 
   ## 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/incubator-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 **more than 7 days** 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?
   4.0.0
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   ### Expected behavior
   The hintManager.setDatabaseShardingValue do not work,In the 
ShardingSphere-example , the `the hint-raw-jdbc-example` project don't work as 
expect,when I choose the type HintType TYPE = HintType.DATABASE_ONLY,the 
expected behavior  should be  all the sql  routing to one datasource which is 
set by   hintManager.setDatabaseShardingValue(1L);  
   ### Actual behavior
   the hint does not work ,sql route to all datasouces,here is the log
   ```
   [INFO ] 2020-02-12 12:56:13,923 --main-- [ShardingSphere-SQL] Rule Type: 
sharding 
   [INFO ] 2020-02-12 12:56:13,924 --main-- [ShardingSphere-SQL] Logic SQL: 
SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = i.order_id 
   [INFO ] 2020-02-12 12:56:13,925 --main-- [ShardingSphere-SQL] SQLStatement: 
SelectSQLStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@59496961,
 tablesContext=TablesContext(tables=[Table(name=t_order, alias=Optional.of(o)), 
Table(name=t_order_item, alias=Optional.of(i))], schema=Optional.absent())), 
projectionsContext=ProjectionsContext(startIndex=7, stopIndex=9, 
distinctRow=false, projections=[ShorthandProjection(owner=Optional.of(i))], 
columnLabels=[order_item_id, order_id, user_id, status]), 
groupByContext=org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext@408b87aa,
 
orderByContext=org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext@79b08632,
 
paginationContext=org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext@787f32b7,
 containsSubquery=false) 
   [INFO ] 2020-02-12 12:56:13,932 --main-- [ShardingSphere-SQL] Actual SQL: 
ds_0 ::: SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = 
i.order_id 
   [INFO ] 2020-02-12 12:56:13,932 --main-- [ShardingSphere-SQL] Actual SQL: 
ds_1 ::: SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = 
i.order_id 
   
   ```
   ### Reason analyze (If you can)
   int the 3.1.0 version .there is a class `DatabaseHintRoutingEngine` to route 
to some certain sharding database without sharding tables,SQL parse and rewrite 
phase will be skipped,however ,in the 4.0.0 verision, there is no class to use 
the value I set in the hintManager, because there is no caller of the method  
`getDatabaseShardingValues`
   ```java
    /**
        * Get database sharding values.
        *
        * @return database sharding values
        */
       public static Collection<Comparable<?>> getDatabaseShardingValues() {
           return getDatabaseShardingValues("");
       }
   ```
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   git clone the project, 
https://github.com/apache/incubator-shardingsphere-example
    switch to 4.0.0, chage the HintType to HintType.DATABASE_ONLY and run the 
   ExampleMain
   ### Example codes for reproduce this issue (such as a github link).
   
https://github.com/apache/incubator-shardingsphere-example/tree/dev/sharding-jdbc-example/other-feature-example/hint-example
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to