Skip to main content

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

How are you reading in the A instance, and what is the size of the collection prior to calling clear?  If you just call em.find using A's primary key, what is the size of the list?

Best regards
Chris

> On Oct 13, 2014, at 4:35 AM, Edson Carlos Ericksson Richter <edsonrichter@xxxxxxxxxxx> wrote:
> 
> 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
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top