FAQ Database Discussion Community


Delete many records per ID - MVC C#

c#,asp.net-mvc,entity-framework,model-view-controller,cascade
The setup for the database I have is, Company can have many Engineer, and can be in many Territory. If I am supposed to remove a company form the list, I need to make a clean exit, so instead of deleting just the Company form the company table. I have...

Is Cascade Delete automatically performed in Entity Framework 1-1 (required) Relationships?

c#,entity-framework,relationship,cascade
Searching about the cascading behavior of Entity Framework, if noticed this answer. On short, the OP is searching for a way to perform cascade delete on 1-0 / 1-1 relationships in Entity Framework, and the best answer contains a snippet on Fluent API applying WillCascadeOnDelete(true); On the DB Context's modelBuilder....

Cascade types in JPA

hibernate,jpa,eclipselink,cascade,jpa-2.1
Given two entities Department and Employee forming a one-to-many relationship from Department to Employee. Since the relationship is quite intuitive, I am leaving out the entity classes. In Department : @OneToMany(mappedBy = "department", fetch = FetchType.LAZY) private List<Employee> employeeList = new ArrayList<Employee>(0); In Employee : @ManyToOne(fetch = FetchType.LAZY) private Department...

CakePHP 3.0.0 cascade dependent deletes

delete,cascade,cakephp-3.0
If I have the following in some model tables; As, Bs, Cs and Ds. They have these associations defined: AsTable: $this->hasOne('Bs', [ 'dependent' => true, 'cascadeCallbacks' => true, ]); BsTable: $this->belongsTo('As', [ 'foreignKey' => 'A_id', ]); $this->hasMany('Cs', [ 'foreignKey' => 'B_id', 'dependent' => true, 'cascadeCallbacks' => true, ]); CsTable: $this->belongsTo('Bs',...

Doctrine2: Adding existing entity to parent, duplicates the parent

php,doctrine2,cascade
I have two related classes (OneToMany): <?php class Container { /** * @var Content[] * @\Doctrine\ORM\Mapping\OneToMany(targetEntity="Content", mappedBy="contents", cascade={"remove"}) */ protected $contents; } class Content { /** * @var Container * @\Doctrine\ORM\Mapping\ManyToOne(targetEntity="Container", inversedBy="contents", cascade={"persist"}) */ public $container; } Now when I add a new Content item the Container will be duplicated...

Doctrine one-to-many relationship AND many-to-one

php,symfony2,doctrine2,cascade,relationships
I have two tables. I want to set up a one-to-many relationship, but also a many-to-one relationship. A Page can have one Background - this is the background of the page. A Page can also have many Backgrounds - this is a collection of user-uploaded backgrounds from which one will...

Hibernate HQL bulk delete don't remove join table values

java,hibernate,jpa,cascade
I've some Jpa entities: @Entity public class Parent{ @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @OrderBy(" date DESC") List<Child> childList = new ArrayList<Child>(); private boolean enabled; } and @Entity public class Child{ private LocalDateTime date; } I want delete parent and all childs with a bulk HQL query....

Is there a way to create a primary key and have it cascade into other tables without re-entering data into the new tables?

mysql,database,cascade
I am working on setting up a database and have created tables that cascade out like using the cascade on update for the foreign key. I have two tables being worked with to try to solve this. My tables are like this: create table Item(Item int(4) not null, EquipName varchar(20),...

What is the correct CascadeType in @ManyToMany Hibernate annotation?

java,hibernate,annotations,many-to-many,cascade
I am trying to model a transient operations solution schema in Hibernate and I am unsure how to get the object graph and behavior I want from the model. The table structure uses a correlation table (many-to-many) to create lists of users for the operation: Operation OperationUsers Users op_id op_id...

python sqlalchemy - can't get cascade delete to work - in mssql manager

python,sql-server,sqlalchemy,cascade
I have this code, thats been mostly taken from the sqlalchemy site class Order(Base): __tablename__ = 'order' id = Column(Integer, Sequence('tri_id_seq'), primary_key=True) text = Column(String(1024), nullable=False) items = relationship("Item", cascade="save-update, delete-orphan, merge, delete", backref="parent") class Item(Base): __tablename__ = 'item' id = Column(Integer, Sequence('tri_id_seq'), primary_key=True) text = Column(String(1024), nullable=False) parent_id =...

Deleting from self-referential inherited objects does not cascade in SQLAlchemy-SQLite

python,sqlite,inheritance,sqlalchemy,cascade
I posted a question previously here where I tried to build a hierarchy using different objects. Each object can have any type of object as it's parent, and any type as children. I solved it by using the Node class suggested by SQLAlchemy here and letting the other objects inherit...

Hibernate - how to use cascade in relations correctly

java,hibernate,jpa,hibernate-mapping,cascade
I'm using hibernate in my spring mvc application and have a question about cascade. I see to many similar questions about it, but none of them can answer my question. Suppose I have User and UserPosition objects. User has a collection of UserPosition and also has one UserPosition as the...

NHibernate Mapping By Code Cascade All-Delete-Orphans

nhibernate,cascade,mapping-by-code
How to set cascade to all-delete-orphans with mapping by code in NHibernate? [Flags] public enum Cascade { None = 0, Persist = 2, Refresh = 4, Merge = 8, Remove = 16, Detach = 32, ReAttach = 64, DeleteOrphans = 128, All = 256, } How can I combine All...