I have a one-to-many association from Project to
ProjectSampleRelationship.
ProjectSampleRelatiosnhip is conceptually a ValueObject though in NH
it is a entity.
Therefore, I want to DELETE and INSERT any updates to a
ProjectSampleRelationship in the <set/> of SampleRelationships.

The unique constraint violation is thrown because NH does the INSERT
before the DELETE on the new association.

I have tried a ton of cascade options and also futzed with the
ProjectSampleRelationship Equals/HashCode. How can I do something like
this using the cascade?

Here is code that removes the relationshp from the
Project.SampleRelationships collection:

 ProjectSampleRelationship subject = Collection.Find
(sampleRelationships,
                                                                r =>
r.Relation.Equals(projectRelatable));
bool removed = sampleRelationships.Remove(subject);
subject.Project=null;
subject.Relation=null;


And here are my mappings:

<!--in Project-->
                <set name="SampleRelationships"
                         access="nosetter.camelcase"
                         inverse="true"
                         cascade="all-delete-orphan" >
                        <key column="ProjectId"/>
                        <one-to-many
class="Cei.MaterialsTesting.Projects.ProjectSampleRelationship,Cei.MaterialsTesting"
 /
>
                </set>

<!-- in ProjctSampleRelationship-->
        <many-to-one name="Project"
                                                 
class="Cei.MaterialsTesting.Projects.Project"
                                                 access="field.camelcase"
                                                 unique-key="ProjectSample"     
/>
       <many-to-one name="Relation"
                                         access="nosetter.camelcase"
                                         
class="Cei.MaterialsTesting.Samples.Sample"
                                         column="Sample"
                                         cascade="none"
                                        unique-key="ProjectSample"/>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to