I have a structure similar to below. I need to only retrieve the lookup data but not have it deleted/saved/updated when a parent/child is deleted/saved/updated. The data in the lookup table is static. I'm using Sprint Data JDBC with Java 11 with Postgres for the database. I understand this is a contrived example but I am not allowed to post the actual code.
@Data
@Table("parent")
public class ParentDTO {
@Id
private long parentId;
private Date createdAt;
@MappedCollection(idColumn="parent_id", keyColumn="parent_id")
private Set<ChildDTO> children;
String name;
}
@Data
@Table("child")
public class ChildDTO {
@Id
private long childId;
private Date createdAt;
private long parentId;
String name;
@MappedCollection(idColumn="lookup_id", keyColumn="lookup_id")
private LookupDTO lookupDTO;
}
@Data
@Table("lookup")
public class LookupDTO {
@Id
private long lookupId;
String name;
private Date createdAt;
}