i have two classes:
a BIlls class:
<code>@IdClass(BillsKey.class)
public class Bills {
@Id
private Long id;
@ManyToOne()
@Id
@JoinColumn(name = "supplier", foreignKey = @ForeignKey(name = "fk_supplier"))
private Suppliers supplier;
}
</code>
<code>@IdClass(BillsKey.class)
public class Bills {
@Id
private Long id;
@ManyToOne()
@Id
@JoinColumn(name = "supplier", foreignKey = @ForeignKey(name = "fk_supplier"))
private Suppliers supplier;
}
</code>
@IdClass(BillsKey.class)
public class Bills {
@Id
private Long id;
@ManyToOne()
@Id
@JoinColumn(name = "supplier", foreignKey = @ForeignKey(name = "fk_supplier"))
private Suppliers supplier;
}
and a Suppliers class:
<code>@Entity
public class Suppliers {
@Id
private Long id;
@OneToMany(mappedBy = "supplier", cascade = CascadeType.ALL)
private Set<Bills> bills;
}
</code>
<code>@Entity
public class Suppliers {
@Id
private Long id;
@OneToMany(mappedBy = "supplier", cascade = CascadeType.ALL)
private Set<Bills> bills;
}
</code>
@Entity
public class Suppliers {
@Id
private Long id;
@OneToMany(mappedBy = "supplier", cascade = CascadeType.ALL)
private Set<Bills> bills;
}
whenever i try to save a bills entity into the database, it raises a duplicate id exception for class. How would i presist the bills entity if i dont specify what supplier it is related too?
i tried recreating the data base and changing the cascade types but those didn’t do anything.