There are two entities:
public class TimeOfSessionEntity { @Id @Column(name = "timeOfSessionId") private Long timeOfSessionId; @Column(name = "timeOfSession") private Timestamp timeOfSessionDate; private Long movieId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "dateOfSessionId") private DateOfSessionEntity dateOfSession; } AND
public class DateOfSessionEntity { @Id @Column(name = "dateOfSessionId") private Long dateOfSessionId; @Column(name = "dateOfSessionTime") private Timestamp dateOfSession; @OneToMany(mappedBy = "dateOfSession", cascade = CascadeType.ALL, fetch = FetchType.EAGER) private Set<TimeOfSessionEntity> timeOfSession = new HashSet<>(); } When I save the TimeOfSessionEntity entity to the database , the entry automatically references the DateOfSessionEntity table with id = 0. those. I want to first create an entry in TimeOfSessionEntity, and then select which id to reference in DateOfSessionEntity. what am I doing wrong? When saving TimeOfSessionEntity, I do not specify a foreign key.
not null default 0- talex