I have an entity "Foo" that has a uni-directional many-to-many relationship to another entity "Bar":
@ManyToMany ( fetch = FetchType.LAZY )
@IndexColumn ( name = "c_index")
@JoinTable ( name = "t_FooBar",
joinColumns = @JoinColumn ( name = "c_FooUid" ),
inverseJoinColumns = @JoinColumn ( name = "c_BarUid" ) )
private List<Bar> bars;
When I execute the following code:
//update the position of 'bar' within the list
foo.bars.add( newIndex, bar);
Hibernate issues the following SQL statement:
/* update collection row Foo.bars */
This, however, causes a constraint violation, since the primary key is (c_FooUid, c_BarUid).
The statement I'd expect is:
i.e. update the index of (foo,bar) instead of setting a new bar for (foo,index).
Any ideas of how I could change that? Am I missing something?
Thanks in advance.