Hello everyone.
I have this java class that's created from an XML file wich ends up being an entity with a lot of relationships (mostly OneToMany, OneToOne relaitonsships) and I need to save/update it in my DB. Saving it works fine but when I need to update it, I'm clueless (been a while since I've done backend stuff). Here's some part of the classes/entities
`@Data
@Entity
public class JourPresse {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqGenerator")
@SequenceGenerator(name = "seqGenerator", sequenceName = "seqNameJP", initialValue = 1, allocationSize = 1)
private Long id;
@JsonFormat
(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy")
@Column(name = "DATE_JP")
private LocalDate date;
private String chaine;
private Integer semaine;
private String editorialDeLaSemaine;
private String editorialNewsletter;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "JOUR_PRESSE_ID", referencedColumnName = "ID")
private Set<RecordPresse> recordsPresse;
}
@Data
@Entity
@JsonIgnoreProperties(ignoreUnknown = true)
public class RecordPresse {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqGenerator")
@SequenceGenerator(name = "seqGenerator", sequenceName = "seqNameRP", initialValue = 1, allocationSize = 1)
private Long id;
private Integer newsLetter;
private String layout;
private String signaletique;
@OneToOne(cascade = CascadeType.ALL)
private CodeEscort codeEscort;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "RECORD_PRESSE_ID", referencedColumnName = "ID")
private Set<Photo> photos;
}`
For the moment I'm doing the following in my JourPresseService (JourPresse being the root of my xml file:
(In my next message). So my question is how I should handle the update of such a class when the one in my project has maybe 30 different relations with other entities?