Cascade

NHibernate - Tries to update entity that does not need to be updated

拜拜、爱过 提交于 2019-12-12 02:49:13
问题 so I have an entity named Event which contains many Reports (one to many) which contains many sources (many to many). I'm facing a problem that I just cant figure out, when I'm trying to update my event, it will try to update the report because of the cascade (which is fine) and it will try to update the report's sources on the join table because of the cascade (which is fine), but for some reason it also tries to update the Source entity, which it shouldn't update because there is no change

ALTER TABLE to add ON DELETE CASCADE statement

落爺英雄遲暮 提交于 2019-12-11 18:48:45
问题 I want to do the following in PostgreSQL (using Hibernate): ALTER TABLE fruits ADD CONSTRAINTS id ON DELETE CASCADE; Obviously, my code above is not working, so I am looking for the correct statement. If I can't do that, then how about the following: I have a bunch of data in my table fruits . The id field in fruits is used as a foreign key by table grapes . I need to delete a specific row in fruits and I want the deletion to cascade to grapes and delete all entries in grapes that has the

How to create one table which shares common id with another and which row gets removed in both tables once it's removed from first

爷,独闯天下 提交于 2019-12-11 16:49:14
问题 How to create one table which shares common id with another and which row gets removed in both tables once it's removed from first? I heard about FOREIGN KEY, REFERENCES but not sure how to actually create such tables. Any example to get me started? 回答1: I think you're either talking about a cascading delete or something really weird that you shouldn't do. :) Info on foreign keys: http://www.postgresql.org/docs/8.3/static/tutorial-fk.html Info on cascading deletes (search the page for "ON

Cascade =“all” not saving child entities

这一生的挚爱 提交于 2019-12-11 11:33:29
问题 I think the object model below is saying a Party and PartyName to have a many to one relatioship. An I think the cascade=all i the Party.hbm sshould be having NHib save the child PartyName(s). But it clearly isn't... Can someone explain why PartyName isn't being saved with Party and what to do to fix? Cheers, Berryl MAPPING <class name="Party" table="Parties"> <id name="Id"> <column name="PartyId" /> <generator class="hilo" /> </id> <discriminator column="Type" not-null="true" type="string" /

soft delete common attributes with regards to cascade recovery

十年热恋 提交于 2019-12-11 11:09:03
问题 What type of fields are generally used to accompany soft delete? Any of these, any others? bool IsDeleted // nice because the default value is 0 (no) just in case date DateDeleted // is this a common one? date DateCreated // more of a temporal db aspect date DateModified // same with respect to created The reason I ask is that when using soft-deletes, cascading must still be implemented in order to maintain integrity. However, the real trick is not cascade deleting, which is rather easy. The

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

≯℡__Kan透↙ 提交于 2019-12-11 10:58:48
问题 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. On the selected answer, a user (CodeMonkey) mentioned: (...) Some have suggested [Required] for cascading delete. This indeed works, but of course, only if it is actually

@OneToMany JPA annotation causes unnecessary sql update and doesn't cascade

冷暖自知 提交于 2019-12-11 09:33:50
问题 I am migrating my app from xml based mapping to JPA annotation based mapping. But this fails only in a simple case. For example, I've the following 3 entities: @Entitiy public class UserAccount { @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(name = "user_account_id", nullable = false, insertable = true, updatable = false) @NotNull private Set<Authority> authorities; @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name="USER_ID", nullable = false) ... get and setter

NHibernate on-delete=“cascade” with relationship on many side

廉价感情. 提交于 2019-12-11 08:52:19
问题 I have an object model like that: Folder - simple structure with name etc. File - complex object containing reference to Folder in which it is contained. Folder doesn't know its Files and I don't want it to know. The relation is many-to-one and should be known on File's side only. Anyway, I would like to rely on my database's ON DELETE CASCADE feature, so that when I remove Folder, I want all Files within that Folder to be deleted automatically. I can't use NHibernate's cascading as there is

SQL Server using triggers and geting rid of ON DELETE CASCADE

人盡茶涼 提交于 2019-12-11 08:17:16
问题 I have 2 tables, A and B. Table B has a foreign key pointing to primary key of table A. The foreign key on table B has ON DELETE CASCADE, so the corresponding records from B is deleted when a record from A is deleted. My requirement is to track all added/updated/deleted records in history tables. I have trigger on each table to insert the records into history tables(AHistories and BHistories tables). I do not like the order ON DELETE CASCADE deletes the records. Trigger A is executed after

Django: cascade on_delete option not working

只谈情不闲聊 提交于 2019-12-11 06:07:07
问题 I am using django 1.2.4 (Confirmed through the shell with import django django.VERSION ) and am attempting to use the on_delete=models.SET_NULL setting on a ForeignKeyField but I get the error: AttributeError: 'module' object has no attribute 'SET_NULL' This is how I was attempting to use the setting: relatedRec = models.ForeignKey(Record, null=True, blank=True, on_delete=models.SET_NULL) The model was already created and I am now trying to alter it. I didnt think that would be a problem but