Yes, you should use the cayenne "removeFrom"/"addTo" methods. These methods help ensure that bi-directional relationships stay consistent for you. Otherwise, you have to manage that by hand.
Robert On Sep 30, 2010, at 9/301:19 PM , gilbertoca wrote: > > > gilbertoca wrote: >> >> Yes, but for some reason it leaves the database in a inconsistent state: >> >> >>> Testcase: >>> com.google.constructor.extras.security.shiro.cayenne.UserCayenneTest: >>> Caused an ERROR >>> Referential integrity constraint violation: "FK_SHIRO_USER_ROLE_ROLE_ID: >>> PUBLIC.SHIRO_USER_ROLE FOREIGN KEY(ROLE_ID) REFERENCES >>> PUBLIC.SHIRO_ROLE(ID)"; SQL statement: >>> delete from SHIRO_ROLE where ID = ? [23003-131] >>> org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: >>> "FK_SHIRO_USER_ROLE_ROLE_ID: PUBLIC.SHIRO_USER_ROLE FOREIGN KEY(ROLE_ID) >>> REFERENCES PUBLIC.SHIRO_ROLE(ID)"; SQL statement: >>> delete from SHIRO_ROLE where ID = ? [23003-131] >>> at >>> org.h2.message.DbException.getJdbcSQLException(DbException.java:316) >>> >> I will try to find the problem! >> >> > I've found the problem. I was using: > userUpdated.getRoles().remove(roleADMIN); > > instead of > > userUpdated.removeFromRoles(roleADMIN); > > So, can't I use those LIST methods with Cayenne? Just the Cayenne one! > > Thanks a lot, Robert. > > Regards, > > Gilberto > > -- > View this message in context: > http://cayenne.195.n3.nabble.com/many-to-many-relation-tp3491p1609999.html > Sent from the Cayenne - User mailing list archive at Nabble.com.
