Reputation: 539
I have following input payload:
"sources":{
"kafka": {"clusterName": "dev", "topics": "topic"}
},
"notification": {
"slack": "alerts",
"email": {
"emailTo": [
"[email protected]",
"[email protected]"
]
}
}
My Entity Classs is as follow :
@Entity
@Data
@Getter
@Setter
public class Details
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
/
..... other fileds
/
private HashMap<String, Object> notification;
private HashMap<String, Object> sources;
}
In DB side I am seeing it's storing it as a bytea datatype, Is this a good practise to store it in this format ? Is there any better way to store this type of fields ?
Upvotes: 1
Views: 1109
Reputation: 331
You might want to define the Details
entity more concisely. As well as altering the mapped table for that entity in the database. For example, you might want to create other entities for sub-keys in the json. Or, just simple new fields.
For a more scalable approach, define a Relational database by creating simple crud tables with their relationship with entities.
Upvotes: 1