Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Creation of M-M-Relation/Association fails


I've got an Entity class Product with a self-relation:
	/** Set of products this one is compatible with.*/
	@ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.REFRESH})
	private Set<Product> compatibleProducts = new HashSet<Product>();

Guess what happens when I add products to this set like this:
	public boolean addCompatibleProduct (Product product) {
		if (compatibleProducts == null)
			compatibleProducts = new HashSet<Product>();
		boolean added = compatibleProducts.add (product);
		if (added)
			product.addCompatibleProduct (this);
		return added;

If you said nothing, you've won. The only SQL that was generated is:
[EL Fine]: 2010-03-15
product SET jdo_version = ? WHERE ((product_id = ?) AND (jdo_version = ?))
	bind => [43, 30, 42]
[EL Fine]: 2010-03-15

What can I do to avoid this? Or is this a bug of EclipseLink?

Kind Regards, Michael

Back to the top