Jooq 强制类型未应用于列
Posted
技术标签:
【中文标题】Jooq 强制类型未应用于列【英文标题】:Jooq forced type not being applied to column 【发布时间】:2021-11-15 04:45:36 【问题描述】:我正在尝试将 jOOQ 与具有 tsvectors 的 postgres 数据库一起使用。我将此添加到我的配置文件中:
<forcedTypes>
<forcedType>
<userType>example.textsearch.TsVector</userType>
<includeTypes>.*tsvector.*</includeTypes>
</forcedType>
</forcedTypes>
我正在尝试将其应用于ts_message_text
列:
[DEBUG] Fetched result : +---------------+----------------+-----------------+------------------------+-----------------+-------------+-----------+-----------+--------------+----------+--------+-----------+
[DEBUG] : |column_name |ordinal_position|data_type |character_maximum_length|numeric_precision|numeric_scale|is_identity|is_nullable|column_default|udt_schema|udt_name|description|
[DEBUG] : +---------------+----------------+-----------------+------------------------+-----------------+-------------+-----------+-----------+--------------+----------+--------+-----------+
[DEBUG] : |sender_id | 1|character varying| 16| null| null|null |YES |null |pg_catalog|varchar |null |
[DEBUG] : |ts_message_text| 2|tsvector | null| null| null|null |YES |null |pg_catalog|tsvector|null |
[DEBUG] : +---------------+----------------+-----------------+------------------------+-----------------+-------------+-----------+-----------+--------------+----------+--------+-----------+
...
INFO] Generating table : ConversationsTexts.java [input=conversations_texts, output=conversations_texts, pk=N/A]
[DEBUG] With column : name=sender_id, matching type names=[character varying, character varying(16), character varying(0), character varying(0,0), character varying(0, 0), varchar, pg_catalog.varchar]
[DEBUG] With column : name=ts_message_text, matching type names=[tsvector, tsvector(0), tsvector(0,0), tsvector(0, 0), pg_catalog.tsvector]
[DEBUG] Type mapping : conversations_texts.sender_id with type character varying
[DEBUG] Type mapping : conversations_texts.ts_message_text with type tsvector
[INFO] Generating record : ConversationsTextsRecord.java
[DEBUG] Type mapping : conversations_texts.sender_id with type character varying
[DEBUG] Type mapping : conversations_texts.ts_message_text with type tsvector
但我明白了:
[WARNING] Unused forced types : There are unused forced types, which have not been used by this generation run.
This can be because of misconfigurations, such as, for example:
- case sensitive regular expressions
- regular expressions depending on whitespace (Pattern.COMMENTS is turned on!)
- missing or inadequate object qualification
- the object to which the configuration was applied in the past has been dropped
Try turning on DEBUG logging (-X in Maven, and <logging/> in jOOQ) to get additional info about the schema
[WARNING] Unused forced type : <priority>0</priority><userType>example.textsearch.TsVector</userType><includeTypes>.*tsvector.*</includeTypes><nullability>ALL</nullability><objectType>ALL</objectType>
【问题讨论】:
【参考方案1】:上面应该有一条额外的日志消息:
[WARNING] Bad configuration for <forcedType/>. Either <binding/> or <converter/>
or <enumConverter/> or <lambdaConverter/> is required
在您的特定情况下,这条消息似乎没有在 jOOQ 3.15.3 中打印出来,不过……似乎是一个日志记录错误。
【讨论】:
以上是关于Jooq 强制类型未应用于列的主要内容,如果未能解决你的问题,请参考以下文章
JOOQ 强制类型将 BigInteger 转换为 BigDecimal 以用于 POSTGRES
带有 JOOQ 的 Spring Boot 收到一条消息“需要一个找不到的 'org.jooq.DSLContext' 类型的 bean”