【问题标题】:DB2 - Foreign key constraint length generated by juplo/hibernate4-maven-plugin is too longDB2 - juplo/hibernate4-maven-plugin 生成的外键约束长度太长
【发布时间】:2016-08-20 11:09:51
【问题描述】:

我收到以下错误:

DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0107N  The name "FK_11CCTW7HP8CNTIYTKPMYGNBF" is too long.  The maximum
length is "18".  SQLSTATE=42622

当我跑步时:

db2 'alter table adviserMediaContent add constraint FK_11cctw7hp8cntiytkpmygnbf foreign key (mediaContentId) references mediaContent;'

Sql 是 juplo/hibernate4-maven-plugin 生成的模式的一部分。 知道如何缩短插件中的约束吗?

【问题讨论】:

  • 你必须运行一个非常旧的版本;我认为在 DB2 9.5 中取消了对大多数对象名称的 18 字节限制(如果您使用 DB2 for LUW)。

标签: hibernate maven db2 maven-plugin ddl


【解决方案1】:

此类名称由 Hibernate 生成。您可以使用 @ForeginKey 注释(不是 JPA,而是 Hibernate 注释)指定约束名称。

在 Hibernate 5 中,您可以使用命名策略来生成约束名称。

【讨论】:

    猜你喜欢
    • 2012-05-09
    • 1970-01-01
    • 2019-06-18
    • 1970-01-01
    • 2015-04-21
    • 2016-08-14
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多