I have a base class:
@MappedSuperclass
public abstract class BaseConfigurationModel extends Model {
@Temporal(value=TemporalType.TIMESTAMP)
public Date lastChangeDate;
@PrePersist
@PreUpdate
public void updateLastChangeDate() {
lastChangeDate = new Date();
dirty = true;
}
}
and an entity:
@Entity
public class Post extends BaseConfigurationModel
{
public String name;
@ManyToMany
public Set<Comments> comments = new HashSet<Comments>();
}
I am using the CRUD module to create and update Posts.
When I update the "name" field the updateLastChangeDate() is invoked,
but when I add or remove elements from the "comments" set the
updateLastChangeDate() is not invoked.
I understand why this happens (http://stackoverflow.com/questions/
1786343/preupdate-not-firing-when-adding-to-a-collection) but I wanted
to know if you have any recommendations as to how this can be done
with Play.
Should I use Hibernate interceptors? Is there a generic JPA solution?
Thanks
public BaseConfigurationModel save() {
// ... udpate your object here
return super.save();
}
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>