Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] EclipseLink 2.5.0 ManyToMany: clear doesn't remove records from relation table?

I've three PostgreSQL tables:

A
A_B
B

I've classes mapped like (just a simplification):

@Entity
class A implements Serializable {
  @Id
  Integer id;

  // the following is a unidirectional ManyToMany
  @ManyToMany(fetch=EAGER)
  List<B> bList;
}


When I add a B object into bList and store the A object, everything works fine:

em.getEntityTransaction().begin();
A.bList.add(new B());
em.merge(A);
em.getEntityTransactoin().commit();


Now, when I execute the following, seems that records from A_B are not removed:

em.getEntityTransaction().begin();
A.bList.clear();
em.merge(A);
em.getEntityTransactoin().commit();


I suppose it should work (I mean, should remove the record from A_B but not B record itself), but it is not. What am I doing wrong?

Thanks,

Edson



Back to the top