最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

constraints - Does JpaBuddy supports ImplicitNamingStrategy of Hibernate in Liquibase Generation? - Stack Overflow

programmeradmin4浏览0评论

We would like to control the naming of contraints when JpaBuddy generates Liquibase from Jpa Entities. When I add the names explicitly e.g. via @ForeignKey JpaBuddy makes them upper case what I don't want. The better approach to implement an Implicit Naming Strategy class for Hibernate JpaBuddy seems not to support those. Is this right or are there any tricks to do so. Here is a sample of this class:

public class HibernateConstraintsNamingStrategy extends ImplicitNamingStrategyJpaCompliantImpl {

  @Override
  public Identifier determineForeignKeyName(ImplicitForeignKeyNameSource source) {
    return Identifier.toIdentifier(
        "fk_" + source.getTableName() + "$" + source.getColumnNames().get(0).getText() + "$pk_"
            + source.getReferencedTableName().getText());
  }

  @Override
  public Identifier determineUniqueKeyName(ImplicitUniqueKeyNameSource source) {
    return Identifier.toIdentifier(
        "uk_" + source.getTableName() + "$" + source.getColumnNames().stream()
            .map(Identifier::getText).collect(Collectors.joining("$")));
  }

JpaBuddy leaves the case of the name of the @ForeignKey annotations JpaBuddy supports implicit naming strategy of hibernate

发布评论

评论列表(0)

  1. 暂无评论