openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb_bou <>
Subject Same insert statement generated multiple times
Date Mon, 28 Sep 2009 13:28:32 GMT

Hi all!

I'm new to OpenJPA and, with the following mapping, the insert statement of
the child entity is generated three times when I cascade persist an Adherent
instance.  This causes a DuplicateKeyException: DB2 SQL error: SQLCODE: -803,

I'm stuck with this problem for more than 4 days.  I would really appreciate
any help!

Here is the parent class:

public class Adherant extends Employe implements Serializable {

// primary key is a generated value of type identity located the super class
Employe (ID_EMPLO)
	@OneToMany(cascade = CascadeType.PERSIST)
	@ElementJoinColumn(name = "ID_EMPLO", referencedColumnName = "ID_EMPLO")
	protected Set<LiensParenteHolder> childrenDB = new
	private transient List<LienParente> children = new
ArrayList<LienParente>(); // collection of enums

        // I also tried this more standard mapping, but got the same error.
	//@OneToMany(mappedBy = "parent", cascade = CascadeType.PERSIST)
	//protected Set<LiensParenteHolder> childrenDB = new
	//private transient List<LienParente> children = new

	void populateDBFields() {
		for (LienParente lien : this.liensParente) {
			if (!liensParenteBd.contains(lien)) {
				liensParenteBd.add(new LiensParenteHolder(lien));

Here the child class:

@Table(name="F_LIEN_PARENTE") // this is name of the view.
public class LiensParenteHolder implements Serializable {

    // Primary key of the table is ID_EMPLO(PK, FK) and COD_LIEN_PARENTE(PK)

    private LienParente lienParente;

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message