Cascade

ManyToMany with cascade all only cascading one way

你离开我真会死。 提交于 2019-12-25 09:12:09
问题 I have 2 entities: 1) User 2) Department. each contains a SET of the other since the relationship between them is manyToMany, I marked (CascadeType.ALL) on the user entity and the department entity and when i do : userX.getDepartments.remove(departmentX); save(userX); it works like intended - it actually implies that departmentX.getUsers.contains(userX) == false. is called implicitly. BUT , when i do departmentY.getUsers.remove(userX); save(departmentY); it doesn't cascade! meaning - i can do

MySQL InnoDB CASCADE?

本小妞迷上赌 提交于 2019-12-25 04:32:56
问题 I am starting to experiment with using InnoDB in web applications. I've setup some tables with a foreign key, but they are not behaving as expected. Here are my table CREATE statements: CREATE TABLE sections ( section_id INT NOT NULL AUTO_INCREMENT, title VARCHAR(30), created_at int(10) NOT NULL, updated_at int(10) NOT NULL, PRIMARY KEY(section_id) ) ENGINE=InnoDB; CREATE TABLE pages ( page_id INT NOT NULL AUTO_INCREMENT, section_idfk INT NOT NULL, PRIMARY KEY(page_id), FOREIGN KEY(section

How to support restoring complex dependencies in a rdb

回眸只為那壹抹淺笑 提交于 2019-12-25 01:44:07
问题 I am having some trouble formulating a solution for this foreseen situation. TableA has a FK to TableB. TableC has a FK to TableA. TableC has a FK to TableD. TableA ------ taId tbId TableB ------ tbId TableC ------ tcId taId tdId TableD ------ tdId A brief series of events: 1) A cascade soft-delete is issued to a record in TableB. This causes all related records in TableA to be soft-deleted, cascading to all related records in TableC being soft-deleted. 2) At a later time, a record in TableD

How to support restoring complex dependencies in a rdb

不羁的心 提交于 2019-12-25 01:29:19
问题 I am having some trouble formulating a solution for this foreseen situation. TableA has a FK to TableB. TableC has a FK to TableA. TableC has a FK to TableD. TableA ------ taId tbId TableB ------ tbId TableC ------ tcId taId tdId TableD ------ tdId A brief series of events: 1) A cascade soft-delete is issued to a record in TableB. This causes all related records in TableA to be soft-deleted, cascading to all related records in TableC being soft-deleted. 2) At a later time, a record in TableD

Cascading FOR loop outputs is there a better python 3 way

夙愿已清 提交于 2019-12-24 18:47:08
问题 Right now, I have a word that I'm search for in a larger string if the word is not found then I insert the word in the larger sting. The output of the first FOR loop is cascaded into a second FOR loop. This work's ok, with one or two but if I had 100's or 1000's of searchs it would be a pain to do this each time is there a better python 3 way? As you can see from the example I'm looking for Monday in the first string monday is there so it just skips the second string does not have Monday so

Delete Cascade is not working with NHibernate

自作多情 提交于 2019-12-24 12:25:04
问题 I have a table Communication which has a reference to PersonCompany. In the mapping for PersonCompany i have defined a Cascade-Delete for this reference: this.HasMany(x => x.Communications) .AsSet() .KeyColumn("PersonCompanyId") .Fetch.Select() .Inverse() .Cascade.Delete(); But when I now execute the fallowing HQL-Query: var sql = "delete from PersonCompany where Person.Id in (:idList) or Company.Id in (:idList)"; with var query = NHibernateHelper.CurrentSession.CreateQuery(sql); query

How do I cascade deletes into a link table using the EF4 fluent API?

久未见 提交于 2019-12-23 18:23:22
问题 I have two tables in an existing (MSSQL 2008 R2) database that are related by a link table. The two tables are "Plan" and "Tips". The link table is "PlanTipLinks". Plans can have many tips, and tips can be associated with multiple plans (i.e. it's a many-to-many relationship). In the application, I only care about the "Plan.Tips" relationship. I don't need the Tip.Plans inverse relationship. The foreign key references in the link table cannot be null. I'm using the following fluent API code

Cascading Deletes/Updates using JPA or Inside of Database?

我只是一个虾纸丫 提交于 2019-12-23 15:33:47
问题 Performance is key: Is it better to cascade deletes/updates inside of the Database or let Hibernate/JPA take care of it? Will this effect the ability to query for the data if cascades are inside of the DBMS? I am using HSQLDB if that matters. 回答1: In the case of cascading updates, you simply cannot do it in application space if you have foreign key constraints in the database. Example: say you have a lookup table for US states, with a primary key of the two-letter abbreviation. Then you have

Using @OneToOne with Cascade.DELETE in embedded type

跟風遠走 提交于 2019-12-23 14:53:41
问题 In an application I use EclipseLink 2.4.1 with Java Persistence 2.0.4. I have a OneToOne mapping in an embedded class. Everything works fine, except deleting. When I try to delete the object containing the embedded class, the following exception occurs. I checked and I am not calling remove on the embedded object by myself somewhere in the code. Does anybody knows how to avoid this error or how to get around it? Exception [EclipseLink-6002] (Eclipse Persistence Services - 2.4.1.v20121003

“Delete Where” cascade delete in Hibernate?

…衆ロ難τιáo~ 提交于 2019-12-23 12:09:00
问题 I am trying to cascade delete rows in a join table via one of its foreign keys and it has another table related to it that I would like to remove all rows associated with this ID as well. So it looks like the diagram below. When I use Session.delete(reqCandObject) with hibernate it works fine and cascades through deleting the One entry from the candidate_jobReq table as well as the associated comments. However, I want to delete all of the candidate_jobReq entries that have a certain candidate