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 2022/12/23 00:44:20 UTC
[GitHub] [shardingsphere] lanxw opened a new issue, #23047: shardingProxy v5.2.1 insert but successfully but cannot return the PK primary
lanxw opened a new issue, #23047:
URL: https://github.com/apache/shardingsphere/issues/23047
When shardingProxy5.2.1 integrates mybatis-plus v3.5.2, calling the insert method successfully, but cannot return the PK primary key value when entity have associated(Use Single Insert is OK),I using the default snowflake algorithm and build in spring boot v2.7.6 and mysql 8
Test Case in shardingJDBC5.2.1 is OKļ¼can return the PK primary
Help, Thanks!
```java
@TableName("bus_statement")
@Data
public class Statement {
@TableId(type = IdType.ASSIGN_ID)
private Long statementNo;
......
}
---------------------------------------------------
@Test
public void testInsertAssociatedData(){
Statement statement = new Statement();
......
statementMapper.insert(statement);
for (int j = 0; j <3 ; j++) {
StatementItem item = new StatementItem();
//statement.getStatementNo() is NULL
item.setStatementNo(statement.getStatementNo());
......
statementItemMapper.insert(item);
}
}
---------------------------------------------------
rules:
- !SHARDING
tables:
bus_statement:
actualDataNodes: customer_data$->{0..1}.bus_statement$->{0..1}
databaseStrategy:
standard:
shardingColumn: customer_phone
shardingAlgorithmName: alg_inline
tableStrategy:
standard:
shardingColumn: statement_no
shardingAlgorithmName: alg_mod
keyGenerateStrategy:
column: statement_no
keyGeneratorName: alg_snowflake
keyGenerators:
alg_snowflake:
type: SNOWFLAKE
shardingAlgorithms:
alg_mod:
type: MOD
props:
sharding-count: 2
alg_inline:
type: INLINE
props:
algorithm-expression: customer_data$->{customer_phone % 2}
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] jeff-lai commented on issue #23047: shardingProxy v5.2.1 insert successfully but cannot return the PK primary
Posted by GitBox <gi...@apache.org>.
jeff-lai commented on issue #23047:
URL: https://github.com/apache/shardingsphere/issues/23047#issuecomment-1373205483
I encountered the same issue.
--
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] strongduanmu commented on issue #23047: shardingProxy v5.2.1 insert successfully but cannot return the PK primary
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #23047:
URL: https://github.com/apache/shardingsphere/issues/23047#issuecomment-1385124792
Hi @lanxw @jeff-lai, I did some research on this issue. In MySQL, we use `auto_increment` to identify the primary key that needs to be auto-incremented. When we execute the insert statement, MySQL will return lastInsertId and updateCount, and the MySQL driver will calculate the auto-increment id value based on updateCount and autoIncrementValue.
Therefore, we cannot support Proxy to obtain auto-increment ids when using the SNOWFLAKE algorithm, because the SNOWFLAKE algorithm is not continuous.
In order to support the MySQL auto-increment id feature, I added isSupportAutoIncrement to KeyGenerateAlgorithm. We can implement our own auto-increment id algorithm based on the SPI interface, and then override isSupportAutoIncrement and return true. At this time, we can support returning auto-increment id.
--
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] strongduanmu commented on issue #23047: shardingProxy v5.2.1 insert successfully but cannot return the PK primary
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #23047:
URL: https://github.com/apache/shardingsphere/issues/23047#issuecomment-1363561241
@lanxw Thank you for your feedback, I will check this problem soon.
--
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] zhaojinchao95 closed issue #23047: shardingProxy v5.2.1 insert successfully but cannot return the PK primary
Posted by GitBox <gi...@apache.org>.
zhaojinchao95 closed issue #23047: shardingProxy v5.2.1 insert successfully but cannot return the PK primary
URL: https://github.com/apache/shardingsphere/issues/23047
--
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