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#a12300977
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to