Page 1 of 1

About Question enthuware.oce-jpad.v6.2.421 :

Posted: Sun Jul 23, 2017 11:07 am
by Susmit
@Entity public class LifecycleCallbackTestEntity implements Serializable {
// attributes and accessor methods not shown

@PostPersist public void m1(){
System.out.println("X");
}

@PostUpdate public void m2(){
System.out.println("Y");
}
}

What will be printed when an application performs the following steps -
1. Begins a transaction 2. Creates the entity 3. Persists the entity 4. Updates the entity 5. Updates the entity again 6. Commits the transaction

Please help me out with the proper reason

Re: About Question enthuware.oce-jpad.v6.2.421 :

Posted: Sun Jul 23, 2017 1:10 pm
by himaiMinh
The @PostPersist will be called. But it is up to the persistence provider to call @PostUpdate.
The spec says that an entity is persisted, the provider may or may not call the pre/post update in the same transaction.