cascading-deletes

Entity Framework cascading delete problems - Foreign key set to null

Hello, I have the following Model which I mapped with the Entity Framework: Mitglied -> Auftrag -> Teilprojekt I have set up everything in the database with foreign keys and "on delete cascade". If I perform some tests on the database everything works fine. The problem arises as soon as I use the Entity Framework to add and especially d...

Nature of Lock is child table while deletion(sql server)

Dear Devs From couple of days i am thinking of a following scenario Consider I have 2 tables with parent child relationship of kind one-to-many. On removal of parent row i have to delete the rows in child those are related to parents. simple right? i have to make a transaction scope to do above operation i can do this as following; (i...

Django foreign keys cascade deleting and "related_name" parameter (bug?)

In this topic I found a good way to prevent cascade deleting of relating objects, when it's not neccessary. class Factures(models.Model): idFacture = models.IntegerField(primary_key=True) idLettrage = models.ForeignKey('Lettrage', db_column='idLettrage', null=True, blank=True) class Paiements(models.Model): idPaiement = mod...

NHibernate : delete error

Hi, Model: I have a model in which one Installation can contain multiple "Computer Systems". Database: The table Installations has two columns Name and Description. The table ComputerSystems has three columsn Name, Description and InstallationId. Mappings: I have the following mapping for Installation: <?xml version="1.0" encoding=...

nhibernate many to many deletes

I have 2 classes that have a many to many relationship. What i'd like to happen is that whenever i delete one side ONLY the association records will be deleted with no concern which side i delete. simplified model: classes: class Qualification { IList<ProfessionalListing> ProfessionalListings } class ProfessionalListing { ...

why when I delete a parent on a one to many relationship on grails the beforeInsert event is called on the child??

hello, I have a one to many relationship and when I try to delete a parent that haves more than one child the berforeInsert event gets called on the frst child. I have some code in this event that I mean to call before inserting a child, not when i'm deleting the parent! any ideas on what might be wrong? the entities: class MenuItem {...

SQL Server Delete - Froregin Key

I have got two tables in Sql Server 2005: USER Table: information about user and so on. COUNTRY Table : Holds list of whole countries on the world. USER_COUNTRY Table: Which matches, which user has visited which county. It holds, UserID and CountryID. For example, USER_COUNTRY table looks like this: ID -- UserID -- CountryID 1 -- 1 ...

What is the correct way to define application-level cascade for many-to-many relationships, using Doctrine/YAML?

Hi, I have this model definition: #/config/doctrine/schema.yml NewsArticle: options: (...) columns: (...) relations: Images: class: Image local: article_id foreign: image_id refClass: ImageToNewsArticle Image: options: (...) columns: (...) relations: NewsArticles: clas...

How do I delete a child entity from a parent collection with Entity Framework 4?

I'm using Entity Framework 4 and have a one-to-many relationship between a parent and child entity. I'm trying to delete a child using the parent repository by removing it from the parent's children collection: public virtual void RemoveChild(Child child) { children.Remove(child); } When I try to save the c...

mysql codeigniter active record m:m deletion

Hi There, I have a table 2 tables that have a m:m relationship, what I can wanting is that when I delete a row from one of the tables I want the row in the joining table to be deleted as well, my sql is as follow, Table 1 CREATE TABLE IF NOT EXISTS `job_feed` ( `id` int(11) NOT NULL AUTO_INCREMENT, `body` text NOT NULL, `dat...

Tree deletion with NHibernate

Hi, I'm struggling with a little problem and starting to arrive at the conclusion it's simply not possible. I have a Table called Group. As with most of these systems Group has a ParentGroup and a Children collection. So the Table Group looks like this: Group -ID (PK) -Name -ParentId (FK) I did my mappings using FNH AutoMapping...

Deletes not cascading for self-referencing entities

I have the following (simplified) Hibernate entities: @Entity @Table(name = "package") public class Package { protected Content content; @OneToOne(cascade = {javax.persistence.CascadeType.ALL}) @JoinColumn(name = "content_id") @Fetch(value = FetchMode.JOIN) public Content getContent() { return content; }...

sql cascading deletes

I have a question about cascading deletes and foreign key references: Let's assume the following tables: ITEMX | ITEMY ------------------ | ------------ ID FKID_ITEMY | ID 1 1 | 1 2 1 | There is a cascade delete on FKID_ITEMY such that if I delete a row in ITEMX, the corre...

SQL Server Multiple cascade sequence

Assume Table A has two children tables, B and C with cascade delete between A-B, and cascade delete between A-C. When a row is deleted in A, the matching rows from B and C are deleted. How does SQL Server determine the order of the Cascades to fire? What I need is to fire the A-C cascade delete before the A-B cascade delete fires. I k...

Hibernate all-delete-orphan on a child class with two parent classes

I'm looking into a problem, where there are two "parent" classes, P and Q that cascade all-delete-orphan to a "child" class, C. My intuition in Hibernate tells this is really a bad idea and I am getting an error message that probably confirms this when the code deletes an instance of P (i.e. session.delete(myP); ): "deleted object would...

delete main row and all children mysql and php

Hi there, I have inherited a PHP project and the client is wanting to add some functionality to their CMS, basically the CMS allows them to create some news, all the news starts with the same content, and that is saved in one table, the actually news headline and articles are saved in another table, and the images for the news are save...

NHibernate Simple Delete Driving Me Mad

Hi, I'm trying to delete an entity (ForumTopic) and have that delete the Posts (ForumPost) within it. Here are my entities: public class ForumTopic { public virtual int TopicID { get; set; } public virtual IList<ForumPost> Posts { get; private set; } ... public ForumTopic() { Posts = new List<ForumPost>();...

LLBLGen Cascading Delete?

Is there any easy way to do what seems best described as a "Cascading Delete" in LLBLGen? An example of what I'm looking for: You've got these tables: Customer: -Id Order: -Id -CustomerId OrderDetail: -Id -OrderId Now, I want to delete a specific Customer and all the things that depend on it (all its orders, and all its orde...

Delete files in directories which match pattern in Unix

How would you delete files which in sub-directories where the sub directory matches a pattern? For e.g. / /deletea /deleteb /dira /deletea/file1 /deleteb/file1 /dira/file1 Now I want to delete all files in the directory where the directory matches the pattern delete* What I came up with is: find . -name 'delete*'| xargs -I{} ...

What are the Pros and Cons of Cascading delete and updates?

Hi, Maybe this is sort of a naive question...but I think that we should always have cascading deletes and updates. But I wanted to know are there problems with it and when should we should not do it? I really can't think of a case right now where you would not want to do an cascade delete but I am sure there is one...but what about up...