-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Need confirmation on on CascadeType.EVICT
PostPosted: Thu Jul 20, 2006 2:32 pm 
Regular
Regular

Joined: Wed Feb 15, 2006 9:09 pm
Posts: 76
I'm using Oracle 10g, and I have a table setup similar to the following:

Code:
CREATE TABLE parent ( parent_id NUMBER PRIMARY KEY );
CREATE TABLE child ( child_id NUMBER PRIMARY KEY, parent_id NUMBER NOT NULL REFERENCES parent ON DELETE CASCADE );


So if I have this:

Code:
class Parent {
  @Id private Long id;
  @OneToMany( mappedBy="parent", cascade=CascadeType.EVICT ) private Set<Child> children;
}


and this:

Code:
class Child {
  @Id private Long id;
  @ManyToOne @JoinColumn( name="parent_id", nullable=false ) private Long parentId;
}


will hibernate OMIT the child delete statements? I'd rather have the database handle the cascading where possible, rather than Hibernate. Is this what EVICT does?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 3:40 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Reading any documentation?

http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#evict(java.lang.Object)

So, if you don't have cascade="delete|all|delete-orphan", Hibernate will not propagate delete to associations.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 4:22 pm 
Regular
Regular

Joined: Wed Feb 15, 2006 9:09 pm
Posts: 76
So the answer is "no". Is there any way to take advantage of "ON DELETE CASCADE" in the database using annotations? I'm going to give the OnDelete annotation a shot, but it looks like it's for DDL generation.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.