I am trying to save a new Dept(in Dept table) with existing users to be assigned to the Dept (in PersonDept table).
When i set the values to the Dept class and save the class, it is giving the exception
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: Person
I have given the cascade option @ManyToMany(cascade=CascadeType.PERSIST), but from the query i got to know that it is trying to save the Person which is not what i am expecting. I want to save a new Dept in the Dept table and the mappings in the PersonDept table with the personIds against the DeptId.