Hi, I have two beans
@Entity(access=AccessType.FIELD) public class BeanNameB implements Serializable { @Id(generate = GeneratorType.AUTO) private int id; private long creationtime; @PrePersist public void prePersist() { this.creationtime = System.currentTimeMillis(); System.out.println("BeanNameB.prePersist"); } } @Entity(access=AccessType.FIELD) public class BeanNameA implements Serializable{ @Id(generate = GeneratorType.AUTO) private int id; private long creationtime; @OneToOne(cascade = CascadeType.ALL) private BeanNameB beanNameB; public BeanNameA(){}; public BeanNameA(long creationtime){ this.creationtime=creationtime; beanNameB = new BeanNameB(); } public void makeNewBeanNameB(){ beanNameB = new BeanNameB(); } }
BeanNameA bean = new BeanNameA(123); manager.persist(bean); //All ok here bean.makeNewBeanNameB(); manager.flush(); //The new BeanNameB is created but no prePersist callback
Provide a runnable test case on http://opensource.atlassian.com/projects/hibernate/secure/Dashboard.jspa
using HEM, I'll check that.
Thanks!