添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account using the Nacos2.2.2 and kingbase8 database update config conflit whit DuplicateKeyException #10353 using the Nacos2.2.2 and kingbase8 database update config conflit whit DuplicateKeyException #10353 justimaging opened this issue Apr 20, 2023 · 7 comments · Fixed by #11405

The intent of these statements is: Try { INSERT NEW CONFIGURATION } catch ( DKE - this means that the configuration exists, so the same configuration needs to be updated. And we only need to update the existing configuration!).

DuplicateKeyException thrown when an attempt to insert or update data results in violation of a primary key or unique constraint.

DataIntegrityViolationException thrown when an attempt to insert or update data results in violation of an integrity constraint.

There are many scenarios where data constraint exceptions will occur, such as: the field is not empty

BTW we can't update an unexist cofnig!

Failed to update config when publish for custom datasource plugin ,the insertOrUpdate logic is deeply bind to the DuplicateKeyException class #10512 扩展数据源配置修改后进行发布出现duplicate key value violates unique constraint "uk_configinfo_datagrouptenant" #10843 dm org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; 违反表[config_info]唯一性约束; nested exception is dm.jdbc.driver.DMException: 违反表[config_info]唯一性约束 #10861

@YunWZ I see the DataIntegrityViolationException and DuplicateKeyException commend, Spring recommend to handle DataIntegrityViolationException but not DuplicateKeyException , should we revert to handle DataIntegrityViolationException ?

commend in DuplicateKeyException

* .... * <p>Consider handling the general {@link DataIntegrityViolationException} * instead, semantically including a wider range of constraint violations. * @author Thomas Risberg

and commend in DataIntegrityViolationException

 * <p>Serves as a superclass for more specific exceptions, e.g.
 * {@link DuplicateKeyException}. However, it is generally
 * recommended to handle {@code DataIntegrityViolationException}
 * itself instead of relying on specific exception subclasses.

@YunWZ I see the DataIntegrityViolationException and DuplicateKeyException commend, Spring recommend to handle DataIntegrityViolationException but not DuplicateKeyException , should we revert to handle DataIntegrityViolationException?

commend in DuplicateKeyException

* .... * <p>Consider handling the general {@link DataIntegrityViolationException} * instead, semantically including a wider range of constraint violations. * @author Thomas Risberg

and commend in DataIntegrityViolationException

 * <p>Serves as a superclass for more specific exceptions, e.g.
 * {@link DuplicateKeyException}. However, it is generally
 * recommended to handle {@code DataIntegrityViolationException}
 * itself instead of relying on specific exception subclasses.

Well, that's a good suggestion, we should handle all exception cases instead of just `DuplicateKeyException.

Of course, in this case we should to do two things:

  • When catching DuplicateKeyException, we need to update record;
  • Otherwise, tell the method's caller some information (for example, throw an exception).Because users may customize their owner database plugin.
  • What do you think?