Thanks for the suggestion. I did try this but it didn't work. But...then I looked closer at the log...What is actually happening is that Hibernate is trying to delete: document_project - which is okay. document - which is okay too... then the project! - NOT okay.
Can anyone see, based upon my mappings, what I can do to remove the associative table record and document but keep the project? Thanks, Mike kla wrote: > > I have a optional one to many relationship between a project and a > document. I have tied these records together using a 3rd an associative > table: > project : project_id > document : document_id > project_document : project_document_id, project_id, document_id > > I'm trying to delete a document but am getting constraint errors. It is > not cascading as I would hope it would. Here are my mappings: > > <class name="Document" table="document"> > <id name="id" column="id" unsaved-value="null"> > <generator class="identity"/> > </id> > > ... > > <join table="document_project" inverse="true" optional="true" > > <key column="document_id"/> > <many-to-one name="project" column="project_id" > not-null="true" cascade="all" /> > </join> > > > </class> > > > <class name="Project" table="project"> > <id name="id" column="id" unsaved-value="null"> > <generator class="identity"/> > </id> > > ... > > <set name="documents" table="document_project" > > <key column="project_id"/> > <many-to-many column="document_id" unique="true" > class="Document" /> > </set> > </class> > > > However, like I said, when I call > docManager.removeDocument(documentId); I get a constraint error. I've > been a way from Hibernate a while. I'm sure its something simple but I > can't figure it out. Should'nt the cascade="all" on the join-table > automatically delete 'document_project' dependent records 1st? > > Any help would be appreciated. > Thanks, > Mike > -- View this message in context: http://www.nabble.com/Hibernate-cascade-delete-not-working-tf4319665s2369.html#a12312100 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
