Hibernate inserting into join table

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>();

Answers


Hard to say with the current level of detail. Is the association bidirectional? Do you have one owning side (with a mappedBy on the other side) defined? Can you enable logging to see the executed queries and identify the one which is causing the problem.


Need Your Help

Retrofit 2.0 + RxJava + Error JSON body

android json retrofit rx-java

I'm pretty new to RxJava and Retrofit and am trying to write my API calls with it. All the API calls return a JSON body on error which is in the general format as,

Is there any API to use with Google Chrome's embedded PDF Viewer?

api google-chrome pdf

I want to make some modifications to the Google Chrome extension which lets us view PDf documents, do you know whether Google Chrome API lets us do it?