Questions tagged [nhibernate-cascade]

37 questions
23
votes
3 answers

Forcing NHibernate to cascade delete before inserts

I have a parent object which has a one-to-many relationship with an ISet of child objects. The child objects have a unique constraint (PageNum and ContentID - the foreign key to the parent).
James Crowley
  • 3,911
  • 5
  • 36
  • 65
13
votes
1 answer

Many to Many: Delete one side, the relationship entry BUT don't delete the other side

I want to delete an user which has many usergroups but those usergroups don't belong exclusivly to this user: other users can also be using this usergroups. And usergroups can exist even if no user references them. I want to map the many-to-many…
David Rettenbacher
  • 5,088
  • 2
  • 36
  • 45
13
votes
1 answer

NHibernate Cascade=save-update"?

Disclaimer: I am an NHibernate noobie so hopefully this question makes sense. I have a many-to-many relationship between two classes something like… public class Entity1 { public virtual Guid EntityId { get; set; } public virtual…
John
  • 605
  • 2
  • 7
  • 17
9
votes
1 answer

Error in Cascade : deleted object would be re-saved by cascade

I have a project by NHibernate implementation and using Lazy Loading. I have two class in this project : Person and Family. Relation between Those two is aggregation, is mean a Person has a list of Person. Maping is :
Ehsan
  • 3,431
  • 8
  • 50
  • 70
8
votes
1 answer

NHibernate Has-Many Collection With Cascading Deletes is Failing

Objective: Create a parent-child relationship such that modifications to the parent's list of children will propagate to all of the children and have NHibernate do the heavy lifting. The parent-child relationship will be a Has-Many on a self…
5
votes
2 answers

How to Delete in a many to many relationship?

I have a many to many relationship: Product has many Categories and Category has Many Products. Say I have Shopping Category Food Category Product A - Shopping Category, Food Category Product B - Shopping Category Now I delete Shopping…
4
votes
4 answers

NHibernate One-To-Many Delete Not Cascading

I have a 'Photo' class and a 'Comment' class. An Photo can have multiple comments assigned to it. I have this configured as a one-to-many relationship within my HBM mapping file, and have set cascade="all-delete-orphan" against the 'Comments' bag…
4
votes
1 answer

NHibernate Cascade Delete on children when clearing a collection

I've searched so many places and still can't find the a answer I'm looking for. I'm using NHibernate 3.2 - Mapping by Code I Have the following Mapping files: public class ParentMapping: EntityMapping { public ParentMapping() …
Jamez
  • 1,559
  • 1
  • 15
  • 26
3
votes
1 answer

NHibernate prevent cascade delete

Suppose I have a class Foo. I also have a view on Foo called Foo_Foo that lists a many-to-many association between Foos. I mapped this association as a simple immutable set on each Foo, with cascade="none":
naasking
  • 2,514
  • 1
  • 27
  • 32
3
votes
0 answers

Cascade delete in Fluent NHibernate using Composite ID on a HasMany Relationship with Integrity constraint

I have an error, and no matter how much I Google it I cannot find a fix for it. I have read and tried to solve it using the following topics. These are the closest I've found related to my issue: Fluent NHibernate and Collections Mapping How to…
2
votes
1 answer

Fluent NHibernate cascading conventions issue - deleted instance passed to update

I normally have everything set to cascade all by using a convention, like so: public class CascadeAllConvention : IHasOneConvention, IHasManyConvention, IReferenceConvention { public void Apply(IOneToOneInstance instance) { …
2
votes
2 answers

NHibernate cascading save

This is trying to insert null into Comment.BlogArticleID. The following GenericADOException appeared: "could not insert: [NHibernate__OneToMany.BO.Comment][SQL: INSERT INTO Comment (Name) VALUES (?); select SCOPE_IDENTITY()]" The following…
user366312
  • 16,949
  • 65
  • 235
  • 452
2
votes
1 answer

How does one handle optional relationships in Hibernate when using cascading delete?

Sorry if this is obvious but we've been scratching our heads over this for several days now. Consider three entities, Parent, Child and X: Parent has a @OneToMany relationship to Child, set up to cascade deletes and orphan removal = true. Child has…
1
vote
1 answer

Not getting NHibernate Cascade Delete Orphan working with Automapping

Having tried several solutions to get NHibernate to delete orphan records. Given the following structure: public class Parent { public virtual ICollection Domains {get;set;} } public class Domain{ public virtual Parent Parent…
1
vote
1 answer

How to delete a collection with cascading in nhibernate?

I have this mapping public class CountryMapping : ClassMap { public CountryMapping() { Id(x => x.Id).GeneratedBy.GuidComb(); Map(x => x.Name).Not.Nullable().NvarcharWithMaxSize(); …
chobo2
  • 83,322
  • 195
  • 530
  • 832
1
2 3