1 package org.hibernate.test.interfaceproxy; 3 4 import java.io.Serializable ; 5 import java.util.Calendar ; 6 import java.util.Iterator ; 7 8 import org.hibernate.CallbackException; 9 import org.hibernate.Interceptor; 10 import org.hibernate.Transaction; 11 import org.hibernate.EntityMode; 12 import org.hibernate.type.Type; 13 14 17 public class DocumentInterceptor implements Interceptor { 18 19 20 public boolean onLoad(Object entity, Serializable id, Object [] state, 21 String [] propertyNames, Type[] types) throws CallbackException { 22 return false; 23 } 24 25 public boolean onFlushDirty(Object entity, Serializable id, 26 Object [] currentState, Object [] previousState, 27 String [] propertyNames, Type[] types) throws CallbackException { 28 if ( entity instanceof Document ) { 29 currentState[2] = Calendar.getInstance(); 30 return true; 31 } 32 else { 33 return false; 34 } 35 } 36 37 public boolean onSave(Object entity, Serializable id, Object [] state, 38 String [] propertyNames, Type[] types) throws CallbackException { 39 if ( entity instanceof Document ) { 40 state[3] = state[2] = Calendar.getInstance(); 41 return true; 42 } 43 else { 44 return false; 45 } 46 } 47 48 public void onDelete(Object entity, Serializable id, Object [] state, 49 String [] propertyNames, Type[] types) throws CallbackException { 50 51 } 52 53 public void preFlush(Iterator entities) throws CallbackException { 54 55 } 56 57 public void postFlush(Iterator entities) throws CallbackException { 58 59 } 60 61 public Boolean isTransient(Object entity) { 62 return null; 63 } 64 65 public int[] findDirty(Object entity, Serializable id, 66 Object [] currentState, Object [] previousState, 67 String [] propertyNames, Type[] types) { 68 return null; 69 } 70 71 public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException { 72 return null; 73 } 74 75 public String getEntityName(Object object) throws CallbackException { 76 return null; 77 } 78 79 public Object getEntity(String entityName, Serializable id) 80 throws CallbackException { 81 return null; 82 } 83 84 public void afterTransactionBegin(Transaction tx) {} 85 public void afterTransactionCompletion(Transaction tx) {} 86 public void beforeTransactionCompletion(Transaction tx) {} 87 } 88 | Popular Tags |