Hibernate annotations cascading doesn't work
Posted
by user304309
on Stack Overflow
See other posts from Stack Overflow
or by user304309
Published on 2010-03-29T14:48:08Z
Indexed on
2010/03/29
15:03 UTC
Read the original article
Hit count: 485
Hi all, I've decided to change hbm.xml style to annotations using hibernate. I had in my hbm.xml:
<hibernate-mapping package="by.sokol.jpr.data">
<class name="Licence">
<id name="licenceId">
<generator class="native" />
</id>
<many-to-one name="user" lazy="false" cascade="save-update" column="usr"/>
</class>
</hibernate-mapping>
And changed it to:
@Entity
public class Licence {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int licenceId;
@ManyToOne(targetEntity=User.class, fetch=FetchType.EAGER, cascade = CascadeType.ALL)
@Cascade(value = { org.hibernate.annotations.CascadeType.SAVE_UPDATE })
private User user;
}
And hibernate doesn't save user on saving. I really need help!
© Stack Overflow or respective owner