Cascade

Hibernate: OneToMany save children by cascade

落爺英雄遲暮 提交于 2019-12-02 22:33:19
In the class Parent there is a list List. When the parent is saved the children which have been added or changed shall be save / updated by hibernate. I've found many explanations on this, however, I just don't get it to work. Parent.class try A @Entity public class Parent { // id and other attributes @OneToMany(mappedBy = "parent") @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.ALL) protected List<child> children; Parent.class try B @Entity public class Parent { // id and other attributes @OneToMany(mappedBy = "parent", cascade = { javax.persistence.CascadeType.ALL }

Oracle-数据字典统计信息

♀尐吖头ヾ 提交于 2019-12-02 16:26:43
数据字典统计信息是用来描述数据字典基表(如TAB$,IND$等)、数据字典基表上的索引。 oracle在执行目标sql的过程中,需要查询TAB$以获得目标sql中相关表对象的统计信息,但是oracle使用内部递归sql(Recursive SQL)访问TAB$时,也会需要TAB$的统计信息,以便CBO优化器知道以什么方式去访问TAB$。 可以使用 dbms_stats.gather_dictionary_stats和dbms_stats.delete_dictionaty_stats分别来收集很删除数据字典统计信息。 当然也可以针对单个数据字典表收集统计信息。 dbms_stats.gather_table_stats('SYS','TAB$',cascade=>true,estimate_percent=>100); SQL> select object_id,object_name from dba_objects where object_name='TAB$'; SQL> select SAVTIME,ROWCNT,BLKCNT,AVGRLN,ANALYZETIME from sys.wri$_optstat_tab_history where obj#=4; 来源: oschina 链接: https://my.oschina.net/u/3862440/blog

NHibernate Definitive Cascade application guide

让人想犯罪 __ 提交于 2019-12-02 14:10:52
Are there any internet resources that have a definitive guide to all of the cascade settings for NHibernate that will include examples of the class structure, HBM and the implications of actions with each of the cascade settings for all of the relationships with NH. Also it would be helpful if there were examples for common associations to be done in the most correct manner such as setting up a states table that you will never end up cascade deleting a state, or that deleting an object that has a CreatedBy User property will never end up deleting the User in a cascade etc. The following is

JPA CascadeType.All doesn't delete parent and child rows

吃可爱长大的小学妹 提交于 2019-12-02 13:19:48
It's always been trouble handling cascades in JPA or Hibernate but i really didn't get it now. I want to delete a parent row brand and childs that are referencing to it. I used CascadeType.ALL but no luck. Here are my models (Transact <- TransactProduct -> Product -> Brand -> Customer), I'm showing only relations for clarity: @Entity @Table(name = "customer") public class Customer { @OneToMany(fetch = FetchType.EAGER, mappedBy = "customer", cascade = CascadeType.ALL) private Collection<Brand> brands; } @Entity @Table(name = "brand") public class Brand implements Serializable { @ManyToOne

problem with NHibernate one-to-many relationship Collection with cascade

风格不统一 提交于 2019-12-02 08:20:26
I have AssetGroup entity with has a one-to-many relation with Asset entity. There is a Entity base class which overrides Equals and GetHashCode . I am following the example of ch 20 parent child <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="TestNHibernate" namespace="TestNHibernate.Models" auto-import="true"> <class name="AssetGroup"> <id name="Id" column="Id" type="guid"> <generator class="guid"></generator> </id> <property name="Name" type="string" not-null="true"/> <set name="Assets" cascade="all" inverse="true" access="field

Grails: Prevent cascading association between two domain classes with multiple relationships

不问归期 提交于 2019-12-02 07:41:18
Consider two domain classes; Job and Quote. A Job has many Quotes but a Job also has an accepted quote. The accepted quote is nullable and should only be set once a particular Quote has been accepted by a user. I have the relationships mapped as follows (simplified for the purpose of illustration). class Job { String title Quote acceptedQuote } class Quote { Job job BigDecimal quoteAmount } The resultant tables are exactly what I require (at least aesthetically) but the problem arises when I go and save a Quote. The Quote is saved successfully with a jobId as per the logic in my code but

How to delete cascade when parentID and childID are on the same table?

廉价感情. 提交于 2019-12-02 05:54:03
问题 I a mysql table named members that basically has two columns: parentID and childID . That way I can create a hierarchical tree based on these two columns, so for example: parentID, ChildID 1,2 2,3 3,4 Will generate a tree in my application with parentID = 1 as the root and 2 as the first node, 3 as the second node, 4 as the third node and so forth. If I want to delete all nodes from a given parentID in this case, how can I accomplish this? 回答1: You just need to ensure that you have set up a

SQL, On delete cascade and on update cascade

一世执手 提交于 2019-12-02 05:31:48
问题 I am new to SQL and I encountered a weird problem. So I have two tables OFFERS and SUPPLIER. Here is the Supplier table. CREATE TABLE "SUPPLIER" ( "S#" NUMBER, "NAME" VARCHAR2(50), "CITY" VARCHAR2(50), PRIMARY KEY ("S#") ENABLE ) And here is the OFFERS table. CREATE TABLE "OFFERS" ( "P#" NUMBER, "S#" NUMBER, "V#" NUMBER, "PR#" NUMBER, CONSTRAINT "PK_OFFERS" PRIMARY KEY ("P#") ENABLE ) So now, when I try to add a Foreign key constraint to the offers table like this ALTER TABLE OFFERS ADD

My 'ON DELETE CASCADE ' does not work

懵懂的女人 提交于 2019-12-02 03:08:27
I have got 3 tables: lt_hdefaults , lt_hperiods and lt_hrules . In lt_hdefaults , there is one row for a property for a particular year. In the lt_hperiods table, there could be more than one period, call them seasons. In the lt_hrules table, there could be more than one rule for each period. Now, what I could not make work: when the user deletes a record from lt_hdefaults , other data related to the deleted record should be removed from lt_hperiods and lt_hrules table. I am trying to achieve this by using FOREIGN KEY (lt_year,lt_id) REFERENCES lt_hdefaults(lt_year,lt_id) ON DELETE CASCADE

SQL, On delete cascade and on update cascade

微笑、不失礼 提交于 2019-12-02 00:23:33
I am new to SQL and I encountered a weird problem. So I have two tables OFFERS and SUPPLIER. Here is the Supplier table. CREATE TABLE "SUPPLIER" ( "S#" NUMBER, "NAME" VARCHAR2(50), "CITY" VARCHAR2(50), PRIMARY KEY ("S#") ENABLE ) And here is the OFFERS table. CREATE TABLE "OFFERS" ( "P#" NUMBER, "S#" NUMBER, "V#" NUMBER, "PR#" NUMBER, CONSTRAINT "PK_OFFERS" PRIMARY KEY ("P#") ENABLE ) So now, when I try to add a Foreign key constraint to the offers table like this ALTER TABLE OFFERS ADD CONSTRAINT FK_SUPPLIERS FOREIGN KEY(S#) REFERENCES SUPPLIER (S#) ON DELETE CASCADE ON UPDATE CASCADE I get