PreUpdate « Map « JPA Q&A

1. EclipseLink JPA @PreUpdate call not persisting

I ran into some similar questions on StackOverflow, tried the solutions, but did not find an answer. I am using a fairly common JPA strategy to set last modified times on ...

2. JPA @Transient fields being cleared before @PreUpdate method is called

I have an User Entity class that I'm trying to do password hashing for. I thought that the easiest way to do this would be to create a password field annotated ...

3. Issues with the usage of @PreUpdate

I have the following class:

public abstract class MappedModel
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false, ...

4. How to identify EJB entity property changes in @PreUpdate?

when persisting (updating) an entity you would call EntityManager.persist(entity) passing the complete entity. It is possible to intercept with @PreUpdate. Does anyone have a recipe how to identify which properties have changed ...

5. Does the JPA 2.0 specification permit @PreUpdate listeners to fire on read-only operations?

The JPA 2.0 specification, section 3.5.2 reads:

The PreUpdate and PostUpdate callbacks occur before and after the database update operations to entity data respectively. These database operations may occur at ...

6. ClassCastException on @PreUpdate

7. Validating Models in @PreUpdate

8. @PreUpdate and other callbacks: what is allowed in them?

I have read in the hibernate docs that it is not allowed to use EntityManager methods from these callbacks. Is the current ("this") entity "managed" during the execution of the @PreUpdate annotated method? Is it allowed to change (non-transient) fields of the current (this) entity in these methods? Will these changes be stored? Will the @PreUpdate method be called again for ...

9. unexpected/inconsistent behaviour in @PreUpdate, @Prepersit

Hibernate version: 3.2 hi i dont know if i hit a bug. Im using JPA and have the following problem. some Entity has: @PrePersist @PreUpdate public void updateEntity1() { this.entity1.setFoo("newFoo"); this.entity1.setBar(someBar); } while Bar is a mapped entity, which is persisted already. Foo is a simple member (String) Entity1 has a ManyToOne relation to Bar. on storing of the above Entity, ...