You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "GuiwenChen (via GitHub)" <gi...@apache.org> on 2024/12/27 08:35:39 UTC
[I] Foreign key constraint problem in a Sharding table [shardingsphere]
GuiwenChen opened a new issue, #34180:
URL: https://github.com/apache/shardingsphere/issues/34180
## Bug Report
### Which version of ShardingSphere did you use?
ShardingSphere-JDBC 5.5.1、Springboot 2.2.1、mysql-connector-java 8.0.16
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
Added when no foreign key constraint exists
### Actual behavior
The "alter table xxx add constraint xxx foreign key xxx" command is executed each time
### Reason analyze (If you can)
For example, the logical table 'orders' is sharded into' orders_0 'and' orders_1 '. The problem appears to be executing "SHOW CREATE TABLE 'db'. 'orders' ". Foreign key constraint information cannot be found because the logical table does not exist.
### Steps to reproduce the behavior
application.properties:
`spring.datasource.initialization-mode=always`
`spring.jpa.hibernate.ddl-auto=update`
Entity Orders:
`@Entity(name = "ORDERS")`
`public class Orders {`
`@OneToOne`
`private EntityCustomer customer;`
`}`
According to the Settings, each time the program is started, the system checks whether the Entity is consistent with the physical table structure。
Through the breakpoint debugging, I found that the problem seems to appear in the `com.mysql.cj.jdbc.DatabaseMetaData.java#extractForeignKeyFromCreateTable` method.
Execute the database query statement :`SHOW CREATE TABLE 'db'. 'orders'`, because the table does not exist, the foreign key constraint information cannot be queried.
Because of this, the sql statement that adds the foreign key constraint is executed each time.
And because the foreign key constraint already exists, an error is reported each time, as follows:
`org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table orders add constraint FKxxxxx foreign key (xxx, xxx) references customer (xxx, xxx)" via JDBC Statement`
--
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
Re: [I] Foreign key constraint problem in a Sharding table [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #34180: Foreign key constraint problem in a Sharding table
URL: https://github.com/apache/shardingsphere/issues/34180
--
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
Re: [I] Foreign key constraint problem in a Sharding table [shardingsphere]
Posted by "GuiwenChen (via GitHub)" <gi...@apache.org>.
GuiwenChen commented on issue #34180:
URL: https://github.com/apache/shardingsphere/issues/34180#issuecomment-2563601311
ok,thx
--
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
Re: [I] Foreign key constraint problem in a Sharding table [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #34180:
URL: https://github.com/apache/shardingsphere/issues/34180#issuecomment-2563569388
The issue involves other third-party dependencies, but our focus is solely on ShardingSphere itself. Since ShardingSphere implements the JDBC interface, standard applications should be functional. We wish to allocate more effort towards enhancing the current version, and therefore will no longer handle such issues. Please read the documentation or provide more effective information when submitting an 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