-->
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.  [ 1 post ] 
Author Message
 Post subject: JPA Cascade always triggered
PostPosted: Wed May 02, 2007 11:34 am 
Newbie

Joined: Wed Sep 20, 2006 4:06 am
Posts: 4
I'm not sure if I'm missunderstanding the definition of the cascade attribute, but I have this problem:

I have a M:N relation and don't want that any changes to the relationship are managed by Hibernate/JPA.

One side is mapped by:

Code:
   @ManyToMany(fetch = FetchType.LAZY, mappedBy  = "aktens")
   public Set<Doktab> getDoktabs() {
      return this.doktabs;
   }


The other side:

Code:
   @ManyToMany(fetch = FetchType.LAZY)
   @JoinTable(
         name="AKTEDOKID",
         joinColumns = {@JoinColumn(name = "VDOKID")},
         inverseJoinColumns = {@JoinColumn(name = "AKTEID")})
   public Set<Akten> getAktens() {
      return this.aktens;
   }


The link is working and I'm able to get the Akten / Doktab Objects from any side.

Problem is: when I change the Set behind getAktens than those changes are written to the DB.

e.g.:
Code:
   @Transactional
   public Doktab getDoktabByVdokid(BigDecimal vdokid, boolean loadAkten) {
      Doktab doktab = doktabDao.findById(vdokid);
      doktab.setAktens(null);
      return doktab;
   }


Result:

17:30:38,913 INFO [STDOUT] Hibernate: select [...] from doktab where doktab0_.VDOKID=?
17:30:39,083 INFO [STDOUT] Hibernate: delete from AKTEDOKID where VDOKID=?

It deletes the relation...

Why? The reference doc says that no cascading operations are executed when the cascade type isn't given. I was assuming that the Set<Akten> is ignored?

Background: I want to transfer the object to the client and I don't need the set there. I'm working with it on the server though.


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

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.