You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new QualifiedJsonType will allow you to save the associated Java type of each JSON Array or Object contained in the JSON column value.
This is going to be useful when the entity property is mapped as an interface or abstract class reference or collection of references.
So, assuming you have the following class hierarchy:
public static abstract class Topic implements Serializable {
private String title;
public Topic() {
}
public Topic(String title) {
this.title = title;
}
}
public static class Post extends Topic {
private String content;
public Post() {
}
public Post(String title) {
super(title);
}
}
public static class Announcement extends Topic {
private Date validUntil;
public Announcement() {
}
public Announcement(String title) {
super(title);
}
}
The QualifiedJsonType will allow you to map that hierarchy either as a List:
@Entity(name = "Book")
@Table(name = "book")
@TypeDef(name = "qualified-json", typeClass = QualifiedJsonType.class)
public static class Book {
@Id
@GeneratedValue
private Long id;
@NaturalId
@Column(length = 15)
private String isbn;
@Type(type = "qualified-json")
@Column(columnDefinition = "jsonb")
private List<Topic> topics = new ArrayList<>();
}
And, when persisting the Post, the following INSERT is generated:
The QualifiedJsonType will be able to persist any class hierarchy, not just the ones annotated with the much more limited Jackson JsonTypeInfo annotation.
The text was updated successfully, but these errors were encountered:
Repository owner
locked and limited conversation to collaborators
Oct 28, 2021
The new
QualifiedJsonType
will allow you to save the associated Java type of each JSON Array or Object contained in the JSON column value.This is going to be useful when the entity property is mapped as an interface or abstract class reference or collection of references.
So, assuming you have the following class hierarchy:
The
QualifiedJsonType
will allow you to map that hierarchy either as a List:And, when persisting the
Post
, the following INSERT is generated:Or, as a
Map
:In which case, the
Post
is saved like this:The
QualifiedJsonType
will be able to persist any class hierarchy, not just the ones annotated with the much more limited JacksonJsonTypeInfo
annotation.The text was updated successfully, but these errors were encountered: