Closed young138120 closed 5 years ago
How is your configuration? Can you give it?
What's more, please set sql.show
= true, so we can get the actual SQLs and logic SQLs.
@yangjwInRiver
spring:
main:
allow-bean-definition-overriding: true
shardingsphere:
datasource:
names: master,slave
master:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: ${spring.datasource.master.driver-class-name}
url: ${mysql.master.url}/faceaccount?useUnicode=true&characterEncoding=utf8&useSSL=false
username: ${spring.datasource.master.username}
password: ${spring.datasource.master.password}
slave:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: ${spring.datasource.slave.driver-class-name}
url: ${mysql.slave.url}/faceaccount?useUnicode=true&characterEncoding=utf8&useSSL=false
username: ${spring.datasource.slave.username}
password: ${spring.datasource.slave.password}
sharding:
tables:
t_account_record:
actual-data-nodes: ds0.t_account_record_20190${1..9},ds0.t_account_record_2019${10..12}
table-strategy:
complex:
sharding-columns: record_no,gmt8_create,account_no
algorithm-class-name: com.core.strategy.dbsharding.FuComplexShardingAlgorithm
# standard:
# sharding-column: gmt8_create
# precise-algorithm-class-name: com.core.strategy.dbsharding.FuPreciseShardingAlgorithm
# range-algorithm-class-name: com.core.strategy.dbsharding.FuRangeShardingAlgorithm
master-slave-rules:
ds0:
master-data-source-name: master
slave-data-source-names: slave
props:
sql:
show: true
Logic SQL: INSERT INTO t_account_record ( id,
record_no,
order_no,
account_no,
trade_type,
amount,
fee_rate,
trade_time,
complete_time,
channel_type,
channel_no,
fund_direction,
status,
owner_type,
track,
gmt8_create ) VALUES ( ?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
? )
2019-08-14 17:52:45.242 INFO 10800 --- [nio-9036-exec-1] ShardingSphere-SQL : SQLStatement: InsertStatement(super=DMLStatement(super=AbstractSQLStatement(type=DML, tables=Tables(tables=[Table(name=t_account_record, alias=Optional.absent())]), routeConditions=Conditions(orCondition=OrCondition(andConditions=[AndCondition(conditions=[Condition(column=Column(name=record_no, tableName=t_account_record), operator=EQUAL, compareOperator=null, positionValueMap={}, positionIndexMap={0=1}), Condition(column=Column(name=account_no, tableName=t_account_record), operator=EQUAL, compareOperator=null, positionValueMap={}, positionIndexMap={0=3}), Condition(column=Column(name=gmt8_create, tableName=t_account_record), operator=EQUAL, compareOperator=null, positionValueMap={}, positionIndexMap={0=15})])])), encryptConditions=Conditions(orCondition=OrCondition(andConditions=[])), sqlTokens=[TableToken(tableName=t_account_record, quoteCharacter=NONE, schemaNameLength=0), SQLToken(startIndex=30)], parametersIndex=16, logicSQL=INSERT INTO t_account_record ( id,
record_no,
order_no,
account_no,
trade_type,
amount,
fee_rate,
trade_time,
complete_time,
channel_type,
channel_no,
fund_direction,
status,
owner_type,
track,
gmt8_create ) VALUES ( ?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
? )), deleteStatement=false, updateTableAlias={}, updateColumnValues={}, whereStartIndex=0, whereStopIndex=0, whereParameterStartIndex=0, whereParameterEndIndex=0), columnNames=[id, record_no, order_no, account_no, trade_type, amount, fee_rate, trade_time, complete_time, channel_type, channel_no, fund_direction, status, owner_type, track, gmt8_create], values=[InsertValue(columnValues=[org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@c11dc0e, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@bfdb2da, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@23494c60, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@24ed7bbd, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@261e2282, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@40932ff9, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@295051c7, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@662ff7c3, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@31f2c3b6, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@6847de96, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@43327430, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@5aba027a, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@7d7295e8, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@2b1747be, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@7b543518, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@717741da])])
2019-08-14 17:52:45.242 INFO 10800 --- [nio-9036-exec-1] ShardingSphere-SQL : Actual SQL: master ::: INSERT INTO t_account_record_201908 (id, record_no, order_no, account_no, trade_type, amount, fee_rate, trade_time, complete_time, channel_type, channel_no, fund_direction, status, owner_type, track, gmt8_create) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ::: [1161576361672871937, RD1161576357721800769201908, PR76650-1618005454-2093736587, AT1161537493854584848, 2, 6.00, 0, 2019-08-14 17:52:34.0, 2019-08-14 17:52:39.389, 4, AT22, 1, 1, 3, TK1161576357679857730, 2019-08-14 17:52:39.391]
2019-08-14 17:52:45.249 INFO 10800 --- [nio-9036-exec-1] ShardingSphere-SQL : Rule Type: sharding
2019-08-14 17:52:45.249 INFO 10800 --- [nio-9036-exec-1] ShardingSphere-SQL : Logic SQL: INSERT INTO t_account_record ( id,
record_no,
order_no,
account_no,
trade_type,
amount,
fee_rate,
trade_time,
complete_time,
channel_type,
channel_no,
fund_direction,
status,
owner_type,
track,
gmt8_create ) VALUES ( ?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
? )
2019-08-14 17:52:45.249 INFO 10800 --- [nio-9036-exec-1] ShardingSphere-SQL : SQLStatement: InsertStatement(super=DMLStatement(super=AbstractSQLStatement(type=DML, tables=Tables(tables=[Table(name=t_account_record, alias=Optional.absent())]), routeConditions=Conditions(orCondition=OrCondition(andConditions=[AndCondition(conditions=[Condition(column=Column(name=record_no, tableName=t_account_record), operator=EQUAL, compareOperator=null, positionValueMap={}, positionIndexMap={0=1}), Condition(column=Column(name=account_no, tableName=t_account_record), operator=EQUAL, compareOperator=null, positionValueMap={}, positionIndexMap={0=3}), Condition(column=Column(name=gmt8_create, tableName=t_account_record), operator=EQUAL, compareOperator=null, positionValueMap={}, positionIndexMap={0=15})])])), encryptConditions=Conditions(orCondition=OrCondition(andConditions=[])), sqlTokens=[TableToken(tableName=t_account_record, quoteCharacter=NONE, schemaNameLength=0), SQLToken(startIndex=30)], parametersIndex=16, logicSQL=INSERT INTO t_account_record ( id,
record_no,
order_no,
account_no,
trade_type,
amount,
fee_rate,
trade_time,
complete_time,
channel_type,
channel_no,
fund_direction,
status,
owner_type,
track,
gmt8_create ) VALUES ( ?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
?,
? )), deleteStatement=false, updateTableAlias={}, updateColumnValues={}, whereStartIndex=0, whereStopIndex=0, whereParameterStartIndex=0, whereParameterEndIndex=0), columnNames=[id, record_no, order_no, account_no, trade_type, amount, fee_rate, trade_time, complete_time, channel_type, channel_no, fund_direction, status, owner_type, track, gmt8_create], values=[InsertValue(columnValues=[org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@c11dc0e, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@bfdb2da, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@23494c60, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@24ed7bbd, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@261e2282, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@40932ff9, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@295051c7, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@662ff7c3, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@31f2c3b6, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@6847de96, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@43327430, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@5aba027a, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@7d7295e8, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@2b1747be, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@7b543518, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@717741da])])
2019-08-14 17:52:45.249 INFO 10800 --- [nio-9036-exec-1] ShardingSphere-SQL : Actual SQL: master ::: INSERT INTO t_account_record_201908 (id, record_no, order_no, account_no, trade_type, amount, fee_rate, trade_time, complete_time, channel_type, channel_no, fund_direction, status, owner_type, track, gmt8_create) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ::: [1161576382317236225, RD1161576357721800769201908, PR76650-1618005454-2093736587, AT22, 4, 6.00, 0, 2019-08-14 17:52:34.0, 2019-08-14 17:52:39.389, 4, AT1161537493854584848, 3, 1, 2, TK1161576357679857730, 2019-08-14 17:52:39.392]
I have the same problem.
Hibernate: insert into dd_bank_2 (application_number, company_id, id) values (?, ?, ?) 2019-08-15 14:47:42.308 INFO 43171 --- [nio-8081-exec-1] ShardingSphere-SQL : Rule Type: sharding 2019-08-15 14:47:42.308 INFO 43171 --- [nio-8081-exec-1] ShardingSphere-SQL : **Logic SQL: insert into dd_bank_2 (application_number, company_id, id) values (?, ?, ?)** 2019-08-15 14:47:42.308 INFO 43171 --- [nio-8081-exec-1] ShardingSphere-SQL : SQLStatement: InsertStatement(super=DMLStatement(super=AbstractSQLStatement(type=DML, tables=Tables(tables=[Table(name=dd_bank_2, alias=Optional.absent())]), routeConditions=Conditions(orCondition=OrCondition(andConditions=[AndCondition(conditions=[Condition(column=Column(name=company_id, tableName=dd_bank_2), operator=EQUAL, compareOperator=null, positionValueMap={}, positionIndexMap={0=1})])])), encryptConditions=Conditions(orCondition=OrCondition(andConditions=[])), sqlTokens=[TableToken(tableName=dd_bank_2, quoteCharacter=NONE, schemaNameLength=0), SQLToken(startIndex=22)], parametersIndex=3, logicSQL=null), deleteStatement=false, updateTableAlias={}, updateColumnValues={}, whereStartIndex=0, whereStopIndex=0, whereParameterStartIndex=0, whereParameterEndIndex=0), columnNames=[application_number, company_id, id], values=[InsertValue(columnValues=[org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@3e451f94, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@1d81965d, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@66e4266c])]) 2019-08-15 14:47:42.309 INFO 43171 --- [nio-8081-exec-1] ShardingSphere-SQL : **Actual SQL: ds2 ::: insert into dd_bank_2 (application_number, company_id, id) VALUES (?, ?, ?) ::: [12314, 2, 64e25235-e5a1-4005-8a53-8f9659b01709]**
how to turn off id keyGenerator in version 4.0.0-RC1?
the field application_number is my primary key,so i no need id
@gholly
SQL: insert into dd_bank_2 (application_number, company_id, id) values (?, ?, ?) Parameters:[12314, 2, 64e25235-e5a1-4005-8a53-8f9659b01709]
If 64e25235-e5a1-4005-8a53-8f9659b01709
is set by SS, what's value you set? Do you assign value tu id?
@yangjwInRiver I want to make true whether you assign id as primary key by annotation of SpringBoot, but not assign value to ID as parameter?
@tristaZero My table field only has applicationnumber and companyid, the primary key is applicationnumber, I don't need id;
@gholly
SQL: insert into dd_bank_2 (application_number, company_id, id) values (?, ?, ?) Parameters:[12314, 2, 64e25235-e5a1-4005-8a53-8f9659b01709]
If
64e25235-e5a1-4005-8a53-8f9659b01709
is set by SS, what's value you set? Do you assign value tu id?@yangjwInRiver I want to make true whether you assign id as primary key by annotation of SpringBoot, but not assign value to ID as parameter?
I am not add annotation that named id in entity parameter
@gholly
Hi, insert into dd_bank_2 (application_number, company_id, id) values (?, ?, ?)
There is no id column in your actual Database, you mean, ss creates a column named id, and gives it a value?
@yangjwInRiver I am sorry to give feedback so late, which column is your primary key? You not add any annotation(Primary key) in entity parameters, right?
@yangjwInRiver I am sorry to give feedback so late, which column is your primary key? You not add any annotation(Primary key) in entity parameters, right?
id is primary key in my db,and i not add any annotation to mark it in my java entity
@gholly Hi,
insert into dd_bank_2 (application_number, company_id, id) values (?, ?, ?)
There is no id column in your actual Database, you mean, ss creates a column named id, and gives it a value?
I mean id column is exitsts in my db table
Sorry, i have no idea about your scenerio and problem, can you upload your example to gitHub, and tell us its url? Therefore i can learn more about your problem. @yangjwInRiver
Closed because no response any more
Sorry, i have no idea about your scenerio and problem, can you upload your example to gitHub, and tell us its url? Therefore i can learn more about your problem. @yangjwInRiver
sry,i was busy working on the projection. there is no time to test this issue,but now the projection manager has closed this issue, so i will not plan to test this issue. but this problem does exist trust me..
I am not configure keyGenerator , but it work I just want to generate id by mysql