`Hello. I want to save the data I took from the Account Code Template table to the Account Code table. The data in these tables has a parent-child relationship (child can also be in the parent. I will add an example visual for your understanding). How can I follow a method to save the data I receive from the Account Code Template to the Account Code table? I share my entity classes.
public class HesapKoduTemplate extends BaseEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(
name = "PARENT_HESAP_KODU_TEMPLATE_ID",
referencedColumnName = "ID"
)
@ManyToOne(fetch = FetchType.LAZY)
private HesapKoduTemplate parent;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true,fetch = FetchType.LAZY)
private List<HesapKoduTemplate> children = new ArrayList<>();
private BirimType birimType;
private String hesapAdi;
private String hesapKodu;
private Long ownerBirimId;
}
public class HesapKodu extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(
name = "PARENT_HESAP_KODU_ID",
referencedColumnName = "ID"
)
@ManyToOne(fetch = FetchType.LAZY)
private HesapKodu parent;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true,fetch = FetchType.LAZY)
private List<HesapKodu> children = new ArrayList<>();
private String hesapAdi;
private String hesapKodu; //Hesap Kodu + Ekonomik Kod , Path
private Long ownerBirimId;
@Column(columnDefinition = "BOOLEAN DEFAULT true")
private Boolean active;
@Column(columnDefinition = "BOOLEAN DEFAULT false")
private Boolean genelPlan;
}
Buğra Taşdemir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.