我试图使用"强制类型"对于使用jOOQ 3.7为我们的Oracle数据库生成类的BOOLEAN。
表格如下:
CREATE TABLE outable_name
(
id INTEGER NOT NULL,
-- ...
some_boolean_field INTEGER DEFAULT 0 NOT NULL
);
使用生成Java类Gradle
。相关部分如下所示:
database() {
name('org.jooq.util.oracle.OracleDatabase')
inputSchema(properties.getProperty('db.user'))
includes('.*')
forcedTypes() {
forcedType() {
name('BOOLEAN')
expression('some_boolean_field')
types('.*')
}
}
}
使用info-output运行gradle-task时会抛出以下错误:
Error while generating table record ***.*** (obfuscated)
java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
at java.util.regex.Matcher.reset(Matcher.java:309)
at java.util.regex.Matcher.<init>(Matcher.java:229)
at java.util.regex.Pattern.matcher(Pattern.java:1093)
at org.jooq.util.AbstractTypedElementDefinition.mapDefinedType(AbstractTypedElementDefinition.java:174)
at org.jooq.util.AbstractTypedElementDefinition.getType(AbstractTypedElementDefinition.java:114)
at org.jooq.util.DefaultColumnDefinition.getType(DefaultColumnDefinition.java:51)
at org.jooq.util.JavaGenerator.refRowType(JavaGenerator.java:1241)
at org.jooq.util.JavaGenerator.generateRecord(JavaGenerator.java:838)
at org.jooq.util.JavaGenerator.generateRecord(JavaGenerator.java:797)
at org.jooq.util.JavaGenerator.generateRecord(JavaGenerator.java:785)
at org.jooq.util.JavaGenerator.generateRecords(JavaGenerator.java:772)
at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:327)
at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:267)
at org.jooq.util.GenerationTool.run(GenerationTool.java:434)
at org.jooq.util.GenerationTool.generate(GenerationTool.java:180)
at org.jooq.util.GenerationTool$generate.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at ...
答案 0 :(得分:1)
打电话&#34;姓名&#34;直接与invokeMethod
:
database() {
name('org.jooq.util.oracle.OracleDatabase')
inputSchema(properties.getProperty('db.user'))
includes('.*')
forcedTypes() {
forcedType() {
delegate.invokeMethod('name', [
'BOOLEAN'
]
)
expression('.*\\.is_.*|.*\\.has_.*')
types('CHAR\\(1\\)')
}
}
}
中的说明