Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Crosstables and Composite Primary Keys

This could occur if both sides of the relationship are writable, have you set one side to be mappedby the other side? If not, any update will cause two inserts to the relation table as the change is seen from both relationships. Not sure why this would occur when updating EclipseLink versions though. What version are you moving from?
Best Regards,
Chris

On 23/09/2010 10:06 AM, Florian Schaetz wrote:
Hi,

I've found a strange problem with EclipseLink 2.1.1. I've got two classes, roles and actions, each action has a set of roles (and via versa, mapped by the actions). In the db, this is a cross table action_roles (role_id, action_id), where both fields toegether form the primary key. Both ManyToMany relations are FetchType.LAZY, using FetchType.EAGER is not an option (because of performance issues).

Now when I try to add an action to a role, I always get an Duplicate Key exception, as the action is already in the set. This should not be a problem, as the equals() and hashcode() methods are both overwritten, so that the role should not be twice inside the set (and it isn't, I checked).

Another aspect of the problem is, that it seems to occur only since I updated to 2.1.1, before the problem didn't occur and the code where is happens hasn't change since then.

Anyone has an idea what the reason could be? I will do some more tests tomorrow, perhaps I'll find a more specific test case.

Regard,

Flo
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top