Reputation: 1161
I have a simple Java class which represents a real-life entity I have to store, such as this.
@Data
public class MappingValue {
private String feature;
private String value;
}
Now, I want to store several of these mappings as a list in a different entity. This entity is stored in a SQL table, and I want to store these mappings as a list of jsonb
objects. I did something like this, but I can't seem to get it to work.
@Column(name = "specifications", columnDefinition = "jsonb")
private List<MappingValue> specifications;
Any ideas? Thanks in advance.
Upvotes: 0
Views: 2361
Reputation: 159
You use an JPA Attribute Converter for that. You implement such a Converter to Store a Complex type in one Column of the Db
Example: https://www.baeldung.com/jpa-attribute-converters
Upvotes: 2