Hibernate inserting into join table

Posted by Karl on Stack Overflow See other posts from Stack Overflow or by Karl
Published on 2010-05-05T09:06:10Z Indexed on 2010/05/05 9:08 UTC
Read the original article Hit count: 189

I got several entities. Two of them got a many-to-many relation. When I do a bigger operation on these entities it fails with this exception:

org.hibernate.exception.ConstraintViolationException: could not insert collection rows:

I execute the operation i a @Transactional context. I don't do any explicit flushing i my daos. The flush is triggered by a query. In the queue are 15 elements (all of the same structure). one of them always fails (but it's always a different one (I checked) and always at a different position).

Does anybody have a hint for me for what I might do wrong?

My Mapping:

@ManyToMany(targetEntity = CategoryImpl.class)
protected Set<Category> categories = new HashSet<Category>();

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about collection