-->
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.  [ 2 posts ] 
Author Message
 Post subject: Persist cascades even if it shouldn't
PostPosted: Fri Oct 28, 2011 11:02 am 
Newbie

Joined: Sun Feb 05, 2006 8:56 pm
Posts: 9
I got these 2 entities:

Code:
@javax.persistence.Entity
public class Book {
   @javax.persistence.EmbeddedId
   private BookPK id;

   private String title;

   @javax.persistence.ManyToOne(fetch = javax.persistence.FetchType.LAZY)
   @javax.persistence.JoinColumns({
         @javax.persistence.JoinColumn(name = "LNGCOD", referencedColumnName = "LNGCOD"),
         @javax.persistence.JoinColumn(name = "LIBCOD", referencedColumnName = "LIBCOD") })
   private Language language;
}

@javax.persistence.Entity
public class Language {
   @javax.persistence.EmbeddedId
   private LanguagePK id;

   private String name;
}


with composed PK's:

Code:
@Embeddable
public class BookPK implements Serializable {
   private Integer bookcod;
   private Integer libcod;
}

@Embeddable
public class LanguagePK implements Serializable {
   private Integer lngcod;
   private Integer libcod;
}


When I retrieve an instance of Book, the relationship is fetched ok.
But if I change something in the Language associated to that Book and then call

Code:
entityManager.persist(book);


the changes to Language are persisted.

From what I know and from what I read, by default the cascade = none, so why does it persist the changes ?
Thanks


Top
 Profile  
 
 Post subject: Re: Persist cascades even if it shouldn't
PostPosted: Thu Nov 03, 2011 5:05 am 
Newbie

Joined: Sun Feb 05, 2006 8:56 pm
Posts: 9
Nobody ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.