Home » Eclipse Projects » EclipseLink » oneToMany with composite key using eclipselink(Mapping of oneToMany with aggregate key using eclipselink gives me ORA-01400)
oneToMany with composite key using eclipselink [message #1614535] |
Fri, 13 February 2015 10:01 |
Jan Andersen Messages: 3 Registered: January 2015 |
Junior Member |
|
|
I am trying to map the classic bi-directional oneToMany using eclipselink. My problem is that when i want to insert a new 'child' i get SQLIntegrityConstraintViolationException.
The database is described like this :
@Entity
@IdClass(KuponPK.class)
@Table(name = "KUPON", schema = "POST", catalog = "")
public class Kupon implements Serializable {
private Integer id;
private String spil;
private Collection<Kombination> kombinationList;
@OneToMany(mappedBy = "kupon", cascade = CascadeType.PERSIST)
public Collection<Kombination> getKombinationList() {
return kombinationList;
}
public class KuponPK implements Serializable {
private Integer id;
private String spil;
@Id
@Column(name = "ID", nullable = false, insertable = true, updatable = true, precision = 0)
public Integer getId() {
return id;
}
@Id
@Column(name = "SPIL", nullable = false, insertable = true, updatable = true, length = 5)
public String getSpil() {
return spil;
}
@Entity
@Table(name = "KOMBINATION", schema = "POST", catalog = "")
public class Kombination {
private Integer id;
private String sorteringOrden;
private Integer sorteringNr;
private Integer antalSpillede;
private BigDecimal odds;
private Kupon kupon;
@ManyToOne
@JoinColumns({@JoinColumn(name = "KUPON_ID", referencedColumnName = "ID", nullable = false, insertable=false, updatable=false),
@JoinColumn(name = "KUPON_SPIL", referencedColumnName = "SPIL", nullable = false, insertable=false, updatable=false)})
public Kupon getKupon() {
return kupon;
}
In my stateless session i have a Kupon object and i create a new Kombination where i set the Kupon and try to merge, but im getting Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("KOMBINATION"."KUPON_ID") which is obvious since its part of primary key
I am setting the Kombination to Kupon and the Kupon to Kombination, but that doesnt make any difference
How can can set the composite foreign key of Kombination ??
[Updated on: Sat, 14 February 2015 14:56] Report message to a moderator
|
|
| | | | |
Goto Forum:
Current Time: Sat Nov 09 03:06:24 GMT 2024
Powered by FUDForum. Page generated in 0.03866 seconds
|