I am currently working on a project with following data structure:
public class PinaColadaId implements Serializable {
private UUID id;
@Temporal(TemporalType.TIMESTAMP)
private Date time;
// Constructor + Getters and Setters
}
@Entity
@Table(name = "pina_coladas")
@IdClass(PinaColadaId.class)
public class PinaColadaEntity {
@Column(columnDefinition = "char(255)")
@Type(type="org.hibernate.type.UUIDCharType")
private @Id UUID id;
private @Id @Temporal(TemporalType.TIMESTAMP) Date time;
@OneToOne(mappedBy = "entityID", cascade=CascadeType.ALL)
private PineappleWrapper pineapple;
@OneToMany(mappedBy = "entityID", cascade=CascadeType.ALL)
private List<CoconutWrapper> coconuts;
// Constructor + Getters and Setters
}
@Entity
public class PineappleWrapper {
private @Id @GeneratedValue long id;
private String manufacturer;
private String origin;
@OneToOne
private PinaColadaEntity entityID;
// Constructor + Getters and Setters
}
@Entity
public class CoconutWrapper {
private @Id @GeneratedValue long id;
private int shipmentNumber;
private int juice;
@ManyToOne
private PinaColadaEntity entityID;
// Constructor + Getters and Setters
}
The issue is that Spring Boot together with Hibernate and JPA correctly generate all the tables in my database, however when I attempt to store PineappleWrapper or CoconutWrapper, it stores all the values of PineappleWrapper and/or CoconutWrapper except for the id and time of the parent. The columns are generated yet they store the value "null".
Any and all help is much appreciated, -AwesomeDude091
Edit: I am aware of the JoinColumn annotation and it proposed implementation in my Wrapper classes, but I do not know how to use them with my two ID variables (id and time)