Questions tagged [cascading-deletes]

The concept of SQL databases deleting rows that refer (via a foreign key) to a deleted row.

The concept of SQL databases deleting rows that refer (via a foreign key) to a deleted row. The deletion is performed recursively and enabled with the ON DELETE CASCADE property of the foreign key.

587 questions
2
votes
1 answer

One to one relationship in MySQL and cascade delete

I have two tables: User and Admin. +-------------------------+ | TABLE : user +-------------------------+ | id: PRIMARY_KEY | username | password +-------------------------+ +-------------------------+ | TABLE: admin +-------------------------+ |…
2
votes
1 answer

Entity framework one to zero or one relationship without navigation property

I hit an issue when trying to delete records due to FK constraints. I therefore went back to the drawing board and am trying to specify how the relationship should work. Here are my code first classes: public class MemberDataSet { [Key] …
2
votes
0 answers

IOS Core Data Cascade Delete Issues

I found a question very similar to mine here, but it was un-replied to and unanswered so I will try again. I may be missing something in regards to cascade deletes and core data. I am used to cascade deletes working as designed in RDBMS apps but…
user2616647
  • 131
  • 9
2
votes
1 answer

Cascading deletion with Ado.net

I have an application which i need to delete a row from the table Client public void Delete_Client(int _id_client) { Data.Connect(); using (Data.connexion) { string s = "Delete From CLIENT…
Lamloumi2
  • 235
  • 1
  • 4
  • 12
2
votes
1 answer

cascade delete multiple levels with nhibernate?

I have a hierarchy of tables 3 levels deep (QualificaionType has many QualificationGroups, which have many Qualifications) mapped like this: // QualificationType HasMany(x => x.QualificationGroups) .Inverse() …
Chris Conway
  • 16,269
  • 23
  • 96
  • 113
2
votes
1 answer

How can I delete related child entities from DB when I set parent entity's value to null using Entity Framework and CodeFirst approach?

For Example I have Order and this order has Reserve field which has ICollection. What I have now is: Order class public class Order { ... public Reserve Reserve {get; private set;} public void ClearReserve() { …
Dmytro
  • 16,668
  • 27
  • 80
  • 130
2
votes
0 answers

Play framework 2.0, delete in oneToOne cascade cause persistence exception

I am using Play 2.0 framework, I have three classes, Patient, Visit and Puberty. Patient and Visit have ManyToOne relationship, whereas Visit and Puberty have a one to one relationship (I know, it's bad practice in database design, but Visit has a…
hook38
  • 3,899
  • 4
  • 32
  • 52
2
votes
1 answer

I get error with cascade deleting in an one-to-many relationship in EF Code First

I am using EF code first, and i generate my codes with EF 4.X DbContext Fluent Generator T4, so now i have have 2 poco Entities(I changed my lists to BindingList to use binding in winForms): public partial class Parent { public Parent() …
Masoud
  • 8,020
  • 12
  • 62
  • 123
2
votes
5 answers

Delete from a table with many foreign keys

Currently I am working in a DB with a tree-like structure. Basically there is one top level table, and there are about 10 tables that have a foreign key on that table. Each of these tables has another 10 tables with a foreign key constraint. Now my…
Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122
2
votes
1 answer

Deleting in cascade with native query

I have a Ebean Entity model with 3 entities related with @OneToMany relationships like this: public class A extends Model { @Id @GeneratedValue public Long id; public String name; @OneToMany(cascade = CascadeType.ALL) …
hiamex
  • 295
  • 2
  • 11
2
votes
1 answer

Removing the entity from the non owning side

I am relatively new to Hibernate so I am still finding hard to understand a few concepts. And one of them is the owning. I have a relationship between 2 objects. Conversation @OneToMany(mappedBy = "conversation", cascade = CascadeType.ALL) private…
Boris Horvat
  • 563
  • 2
  • 13
  • 28
2
votes
3 answers

Integrity constraint violation by delete sql statement

I get an Integrity constraint violation by a delete sql statement. This happens because the id of a table is used in another table as Primary Key. However I want to delete them anyway, by using CASCADE. But what's the correct syntax for hsqldb?
maximus
  • 11,264
  • 30
  • 93
  • 124
2
votes
1 answer

Hibernate deletes record from many-to-many association table after updating

In my teamwork oriented app I have many-to-many relationship between User and Team, so hibernate creates association table. Problem is, that after updating the User which has Team, hibernate deletes corresponding association record from USER_TEAM…
2
votes
1 answer

Modeling an N-level tree in SQL Server with cascading deletes

I need to model an n-level tree in SQL Server. I originally did something like this to create a Node table: [Id] [bigint] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](50) NOT NULL, [ParentId] [bigint] NULL It's a self referential table, where…
2
votes
1 answer

Deleting rows from multiple related tables

There are three tables related one-to-one on the identifier. I need to delete all the records from the three tables that match the criteria A.ID = B.ID = C.ID Now I do it in the following way: DECLARE CURSOR CUR IS SELECT C.ID FROM A …
abg
  • 2,002
  • 7
  • 39
  • 63