在MariaDB中,我有一个如下表:
CREATE TABLE `REFERENCE_MANAGEMENT_REQUESTS` (
.. stuff ..
UNIQUE KEY `REFERENCE_MANAGEMENT_REQUESTS_key_UN` (`rmr_key`),
.. more stuff ..
)
jOOQ由此生成:
public static Index REFERENCE_MANAGEMENT_REQUESTS_REFERENCE_MANAGEMENT_REQUESTS_KEY_UN = Internal.createIndex("REFERENCE_MANAGEMENT_REQUESTS_key_UN", ReferenceManagementRequests.REFERENCE_MANAGEMENT_REQUESTS, new OrderField[] { ReferenceManagementRequests.REFERENCE_MANAGEMENT_REQUESTS.RMR_KEY }, true);
如果我比dslContext.ddl(schema)
多,它将生成以下内容:
create table REFERENCE_MANAGEMENT_REQUESTS (
.. stuff ..
constraint KEY_REFERENCE_MANAGEMENT_REQUESTS_REFERENCE_MANAGEMENT_REQUESTS_key_UN unique (rmr_key)
)
其结果是:
java.sql.SQLException: Identifier name 'KEY_REFERENCE_MANAGEMENT_REQUESTS_REFERENCE_MANAGEMENT_REQUESTS_key_UN' is too long
。
是否可以修改生成器(生成较短的常量名称)或ddl函数(使用实际名称而不是变量名称)的行为?
修改
哎呀..没有足够仔细地阅读它。实际错误中提到了这一点:
public static final UniqueKey<ReferenceManagementRequestsRecord> KEY_REFERENCE_MANAGEMENT_REQUESTS_REFERENCE_MANAGEMENT_REQUESTS_KEY_UN = Internal.createUniqueKey(ReferenceManagementRequests.REFERENCE_MANAGEMENT_REQUESTS, "KEY_REFERENCE_MANAGEMENT_REQUESTS_REFERENCE_MANAGEMENT_REQUESTS_key_UN", ReferenceManagementRequests.REFERENCE_MANAGEMENT_REQUESTS.RMR_KEY);