apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
20k stars 6.76k forks source link

sharding-jdbc-core v 4.0.0 not support mybatis about xml with multi table? #4527

Closed phoema closed 4 years ago

phoema commented 4 years ago

Question

For English only, other languages will not accept. when I use with hintManager mode define a java class public class HintShardingStrategy implements HintShardingAlgorithm I write rule in hint-databases-only.yaml like this shardingRule: tables: quartz_user_monitor: databaseStrategy: hint: #Hint分片策略 algorithmClassName: com.smarttree.manage.config.mybatis.HintShardingStrategy biz_fee: databaseStrategy: hint: #Hint分片策略 algorithmClassName: com.smarttree.manage.config.mybatis.HintShardingStrategy biz_official_notice: databaseStrategy: hint: #Hint分片策略 algorithmClassName: com.smarttree.manage.config.mybatis.HintShardingStrategy case_info: databaseStrategy: hint: #Hint分片策略 algorithmClassName: com.smarttree.manage.config.mybatis.HintShardingStrategy sys_fee: databaseStrategy: hint: #Hint分片策略 algorithmClassName: com.smarttree.manage.config.mybatis.HintShardingStrategy

use sql in mapper.xml like select * from a left join b on xxx left join c on xxx

but it does not work good. can not go into dosharding function.

when I tried with single table like delete or insert .it work good. can go into dosharding function

delete * from a where xxx insert

what am i wrong?

By the way: I change mode with PreciseSharding like this: public class StdDatabaseShardingAlgorithm implements PreciseShardingAlgorithm {

mutiy table select do not work too.

what am i wrong?

image image

kimmking commented 4 years ago

Ensure your mapper using shardingDataSource

You can learn more from https://github.com/apache/incubator-shardingsphere/tree/master/examples/sharding-jdbc-example/sharding-example

phoema commented 4 years ago

thanks a lot!

another question Can I define only the default sharding database rules with not define tableRule

I want the table structure of each instance is exactly the same based on the every database splitting operation of tenantid

Is there any way to use table rules without defining each table

I try to comment out the table definition in the tablerule, but console log: image

org.apache.shardingsphere.underlying.common.config.exception.ShardingSphereConfigurationException: Cannot find table rule and default data source with logic table: 'QRTZ_TRIGGERS'

QRTZ_TRIGGERS must define in shardingRule.tables.QRTZ_TRIGGERS ? have a default way to define all tables?

menghaoranss commented 4 years ago

thanks a lot!

another question Can I define only the default sharding database rules with not define tableRule

I want the table structure of each instance is exactly the same based on the every database splitting operation of tenantid

Is there any way to use table rules without defining each table

I try to comment out the table definition in the tablerule, but console log: image

org.apache.shardingsphere.underlying.common.config.exception.ShardingSphereConfigurationException: Cannot find table rule and default data source with logic table: 'QRTZ_TRIGGERS'

QRTZ_TRIGGERS must define in shardingRule.tables.QRTZ_TRIGGERS ? have a default way to define all tables?

@phoema , Which version of ShardingSphere did you use? Can you provide a complete configuration.

terrymanu commented 4 years ago

Do not support subquery for 4.x

phoema commented 4 years ago

my userd version is 5.0.0-RC1-SNAPSHOT with master branch source. Will future versions support the subquery or the support plan?

Special business methods are complex to write

for example subquery:

SELECT FROM ( SELECT tbl_biz., tmp.payer_name AS payer_name FROM biz_fee_unipay tbl_biz LEFT JOIN ( SELECT t1.type AS payer_type, t1.name AS payer_type_name, t2.value AS payer_id, t2.name AS payer_name FROM ( sys_dict_type t1 LEFT JOIN sys_dict_data t2 ON ((

phoema commented 4 years ago

4582

phoema commented 4 years ago

3841