2011-07-26 13 views

答えて

1

あなたはグローバルEntityInterceptorを実装することができます

@PrePersistのようないくつかのアノテーション駆動型のソリューションですが、彼らはのみで動作し
public class GlobalEntityInterceptor 
    extends EmptyInterceptor { 
    @Override 
    public boolean onSave(java.lang.Object entity, java.io.Serializable p2, java.lang.Object[] p3, java.lang.String[] p4, org.hibernate.type.Type[] p5) { 
    //first save - you can modify your entity fields 
} 
    @Override 
    public boolean onFlushDirty(java.lang.Object entity, java.io.Serializable p2, java.lang.Object[] p3, java.lang.Object[] p4, java.lang.String[] p5, 
            org.hibernate.type.Type[] p6) { 
    //modification - you can modify your entity fields 

} 

数少ないenvironments

1

、あなただけの値を提供します。

@Version 
    private Timestamp lastUpdate; 
0

は、あなたが使用できるいくつかのデータ、すなわちでエンティティを移入するためのインターセプタをハイバネーション:

自動的エンティティへのすべての変更にタイムスタンプを更新するためには、タイムスタンプフィールドに@Versionを使用することができます。作成日などの詳細は、こちらをお読み

についてinterceptors

+0

私は非常にあなたの投票に落ち着きました:)答えは恐ろしいです – Shahzeb

関連する問題