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