jooq deserialize a polymorphic class

Viewed 28

I am using JOOQ to manipulate the database,now i have a problem. There is a polymorphic class OrderEntry

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true)
@JsonSubTypes(value = {
        @JsonSubTypes.Type(value = ReissueOrderEntry.class, name = "reissue"),
        @JsonSubTypes.Type(value = RawOrderEntry.class, name = "raw"),
        @JsonSubTypes.Type(value = FreebieOrderEntry.class, name = "freebie"),
        @JsonSubTypes.Type(value = ReplaceOrderEntry.class, name = "replace")
})
public class OrderEntry extends OrderObject {
    String type;
}

It will be deserialized into different objects according to the field 'type'. But in jooq's deserialization it will only be deserialized as OrderEntry. code

How can i solve it?

1 Answers

I'm assuming you're trying to use the built-in ConverterProvider logic that makes use of Jackson, e.g. when writing things like:

record.into(OrderEntry.class);

jOOQ loads Jackson from the classpath without any additional modules / plugins loaded. If you wish to use additional plugins, then you'll have to roll your own ConverterProvider, which implements loading additional plugins.

Related