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

Moderator: admin

Post Reply
Susmit
Posts: 1
Joined: Tue May 23, 2017 1:05 pm
Contact:

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

Post 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

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 30 guests