Java JOOQ-未应用内联转换器
在我的Java JOOQ-未应用内联转换器,java,sql,enums,jooq,Java,Sql,Enums,Jooq,在我的build.gradle中,我在我的forcedTypes中使用了一个转换器。这在我需要的地方很好用 forcedType { userType = 'java.util.List<stormsensor.thor.dto.telemetry.FlowEventType>' converter = 'stormsensor.thor.config.jooq.StringToFlowEventTypeListConverter' includeExpres
build.gradle
中,我在我的forcedTypes
中使用了一个转换器。这在我需要的地方很好用
forcedType {
userType = 'java.util.List<stormsensor.thor.dto.telemetry.FlowEventType>'
converter = 'stormsensor.thor.config.jooq.StringToFlowEventTypeListConverter'
includeExpression = '.*\\.FLOW_EVENTS'
includeTypes = '.*'
}
这就是我正在研究的模型:
@Data
@NoArgsConstructor
public class BatchNotificationRuleModel implements Serializable {
private static final long serialVersionUID = 1L;
private List<FlowEventType> notifications;
private List<MessageProtocolType> protocols;
}
@数据
@诺尔格构装师
公共类BatchNotificationRuleModel实现可序列化{
私有静态最终长serialVersionUID=1L;
私人名单通知;
私有列表协议;
}
我错过什么了吗
更新:
我能够使用
//...
.groupBy(MONITORING_POINT_ID)
.fetchStream().map(e -> {
Converter<String, List<FlowEventType>> converter = new StringToFlowEventTypeListConverter();
List<FlowEventType> notifications = e.get(field(name("notifications"), String.class), converter);
return BatchNotificationRuleModel.builder().notifications(notifications).build();
}).collect(toList());
/。。。
.groupBy(监控点ID)
.fetchStream().map(e->{
Converter Converter=新StringToFlowEventTypeListConverter();
列表通知=e.get(字段(名称(“通知”)、String.class、转换器);
返回BatchNotificationRuleModel.builder().notifications(通知).build();
}).collect(toList());
我应用的初始转换器与后期映射转换之间的区别是什么?虽然可以合理地预期将使用参数字段的名称和类型进行类型强制,但事实并非如此。根据Javadoc: 基于其他字段的名称为此字段创建别名 为了将表达式强制为所需的数据类型,必须手动执行以下操作:
groupConcatDistinct(通知\规则.流程\事件\类型)
.强制(列表类型)
.as(“通知”)
看
@Data
@NoArgsConstructor
public class BatchNotificationRuleModel implements Serializable {
private static final long serialVersionUID = 1L;
private List<FlowEventType> notifications;
private List<MessageProtocolType> protocols;
}
//...
.groupBy(MONITORING_POINT_ID)
.fetchStream().map(e -> {
Converter<String, List<FlowEventType>> converter = new StringToFlowEventTypeListConverter();
List<FlowEventType> notifications = e.get(field(name("notifications"), String.class), converter);
return BatchNotificationRuleModel.builder().notifications(notifications).build();
}).collect(toList());