I have a JSON file that looks like this...
{
"accountId": "123",
"parties":[
{
"name": "John Doe"
}
]
}
I can parse this fine using something like
public class Account{
private String id;
@JsonProperty("parties")
private List<Party> parties;
}
public class Party{
private String name;
}
However, the SQL table PARTY contains a compound key as the ID. This is a compound key of the name and the parent's account id. Is there a way I can do this without separate classes? I tried this...
@JsonBackReference
private Account parent;
public class GetIdConverter implements AttributeConverter<String, String> {
@Override
public String convertToDatabaseColumn(String b) {
if(parent == null){
logger.error("couldn't find the parent");
}
return parent.getId();
}
@Override
public String convertToEntityAttribute(String s) {
return s;
}
}
But when I try to insert I get...
IdentifierGenerationException: ids for this class must be manually assigned before calling save()