Questions tagged [cascade]

Cascade refers to a table-definition keyword in relational databases; it instructs the query engine to take a certain action (delete, update), when a primary key is modified, on tables linked by a foreign key.

Cascade is a keyword that helps define the behavior of database tables linked by a foreign key, when the primary table is changed. If cascade is specified in the table definition, then, for example:

  • if a row in the primary table is deleted, the corresponding rows in the linked table can be deleted
  • if a primary key is updated, then the corresponding rows can be updated
1381 questions
12
votes
4 answers

remove ON DELETE CASCADE

I have a child table. and foreign key there with ON DELETE CASCADE while creating the table. There are no records either in child or parent table. I want the primary key, foreign key to be as they are but want to remove only the CASCADING option…
Raghav
  • 195
  • 1
  • 3
  • 6
12
votes
2 answers

NHibernate mapping by code (Loquacious) - Cascade options

I have a question on Cascade enum options behavior when using NHibernate Mapping By Code. Enum has following options: [Flags] public enum Cascade { None = 0, Persist = 2, Refresh = 4, Merge = 8, Remove = 16, Detach = 32, …
Cortlendt
  • 2,190
  • 4
  • 29
  • 50
11
votes
1 answer

tsql script to add delete cascade to existing tables

is there a script that can be used to enable cascaded deletion for existing tables. Thanks.
mike
  • 113
  • 1
  • 1
  • 4
11
votes
1 answer

Is SQL Server DRI (ON DELETE CASCADE) slow?

I've been analyzing a recurring "bug report" (perf issue) in one of our systems related to a particularly slow delete operation. Long story short: It seems that the CASCADE DELETE keys were largely responsible, and I'd like to know (a) if this…
Aaronaught
  • 120,909
  • 25
  • 266
  • 342
11
votes
4 answers

Hibernate Delete Cascade

I Have one entity [Project] that contains a collection of other entities [Questions]. I have mapped the relation with a cascade attribute of "all-delete-orphan". In my DB the relation is mapped with a project_id (FK) field on the questions table.…
Pablo Fernandez
  • 103,170
  • 56
  • 192
  • 232
11
votes
2 answers

INSTEAD OF Triggers and CASCADE paths

Let's say I have 3 tables in a hierarchy: TableA -> TableB -> TableC TableC has a foreign key relationship with TableB, and TableB has a foreign key relationship with TableA. If i delete a record in TableA, it should cascade delete down through the…
Brett Postin
  • 11,215
  • 10
  • 60
  • 95
10
votes
2 answers

Hibernate 3 On delete cascade

I have a many-to-one mapping on bookings. A booking must belong to a room. And a room can have several bookings. If a room is deleted, I would like all the bookings on that room to be deleted as well. How would i go about doing this using hibernate…
user829237
  • 1,719
  • 8
  • 37
  • 61
10
votes
7 answers

How to find if a referenced object can be deleted?

I have an object called "Customer" which will be used in the other tables as foreign keys. The problem is that I want to know if a "Customer" can be deleted (ie, it is not being referenced in any other tables). Is this possible with Nhibernate?
Jey Geethan
  • 2,235
  • 5
  • 33
  • 60
10
votes
2 answers

JPA+Hibernate - Cycles in entity relationships - Cascade strategy

I have a set of entities that connect to each other forming a cycle i.e., parent entity P has two one-to-many relationships with two child entities C1 and C2 and each one of these has a one-to-many relationship with another entity A. Entity A…
Stelinio
  • 109
  • 1
  • 5
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
9
votes
3 answers

Java Spring cascade elementcollection delete

For some reason my delete is not cascading when I try to delete the parent element which has an elementcollection in it, the two classes are as follows: @Entity @Table(name="Timestamps") @JsonIgnoreProperties(ignoreUnknown = true) public class…
IDKWhatImDoing
  • 137
  • 1
  • 13
9
votes
1 answer

How to persist a new entity containing multiple identical instances of another unpersisted entity with spring-boot and JPA?

Overview: I'm building a spring-boot application which, in part, retrieves some entities from an external REST service and compares it to previous versions of the entity held locally in a database. I'm injecting EntityManager with…
Chris
  • 409
  • 3
  • 17
9
votes
2 answers

Hibernate - One to many relationship and orphanRemoval cascade

I have a basic one to many relation parent / child like in the chapter 21 of Hibernate references book. The cascade is only from child to parent (persist cascade only because I don't want to delete the parent if I delete a child). When I add a child…
Cedric Thiebault
  • 1,015
  • 1
  • 15
  • 28
9
votes
1 answer

Hibernate doesn't generate cascade

I have a set hibernate.hbm2ddl.auto to create so that Hibernate creates the tables in mysql for me. However, it doesn't seem that hibernate correctly adds Cascade on the references in the table. It does however work when I for instance delete a row,…
Shervin Asgari
  • 23,901
  • 30
  • 103
  • 143
9
votes
2 answers

Matlab Cascade train for bees counting

I'm student in agronomy and the subject of my final year study is to assess the number of bees in pictures. I tried some methods (thresolding, template matching with ciratefi algorithm or with imageJ) but none works fine. I'm a beginer with matlab…
Hgwen
  • 91
  • 3