Используя Postgres, я могу заставить столбцы TIMESTAMPTZ сопоставляться с Instant с помощью принудительного типа в сопоставлении jOOQ.
create table if not exists public.items
(
id varchar(100) not null,
modified timestamptz not null,
name varchar(100) not null,
"sellByDate" date,
quality integer not null
);
forcedTypes {
forcedType {
name = 'instant'
includeExpression = '.*'
includeTypes = 'TIMESTAMPTZ'
}
}
Когда я пытаюсь сделать то же самое с H2
create table if not exists public.items
(
id varchar(100) not null,
modified timestamp with time zone not null,
name varchar(100) not null,
"sellByDate" date,
quality integer not null
);
forcedTypes {
forcedType {
name = 'instant'
includeExpression = '.*'
includeTypes = 'TIMESTAMP WITH TIME ZONE'
}
}
Сопоставление не применяется
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, --debug in Gradle, and <logging/> in jOOQ) to get additional info about the schema
16:42:53 WARNING Unused forced type : <priority>0</priority><name>instant</name><autoConverter>true</autoConverter><includeExpression>.*</includeExpression><includeTypes>TIMESTAMP WITH TIME ZONE</includeTypes><nullability>ALL</nullability><objectType>ALL</objectType>
Может ли кто-нибудь помочь диагностировать проблему, пожалуйста?
Подсказка – в предупреждении: «(Шаблон.КОММЕНТАРИИ включен!)». Это означает, что пробелы в регулярном выражении игнорируются классом Pattern
Java. Обычно это полезно для регулярных выражений, отформатированных следующим образом:
(
# Comment
SOME_VALUE
# Other comment
| SOME_OTHER_VALUE
)
В этом случае вы не хотите, чтобы пробелы (или комментарии) были частью регулярного выражения. Конечно, вы не хотите, чтобы это применялось к вашему регулярному выражению, поэтому избегайте пробелов:
includeTypes = 'TIMESTAMP\\ WITH\\ TIME\\ ZONE'
Или:
includeTypes = 'TIMESTAMP\\sWITH\\sTIME\\sZONE'
@DuncanMcGregor: На тот случай, если вы не используете последнюю версию jOOQ, также была ошибка jOOQ: github.com/jOOQ/jOOQ/issues/14866
Это помогает, спасибо. Если кто-то еще идет по этому пути, обратите внимание, что обработка H2 TIMESTAMP With TIME ZONE не работает так же, как TIMESTAMPTZ в Postgres, поэтому вам потребуется некоторое тестирование летнего времени!