documentinterceptor.java

来自「介绍了hibernate的入门有一些基本常用的事例」· Java 代码 · 共 88 行

JAVA
88
字号
//$Id: DocumentInterceptor.java,v 1.5 2005/02/12 07:27:26 steveebersole Exp $package org.hibernate.test.interfaceproxy;import java.io.Serializable;import java.util.Calendar;import java.util.Iterator;import org.hibernate.CallbackException;import org.hibernate.Interceptor;import org.hibernate.Transaction;import org.hibernate.EntityMode;import org.hibernate.type.Type;/** * @author Gavin King */public class DocumentInterceptor implements Interceptor {	public boolean onLoad(Object entity, Serializable id, Object[] state,			String[] propertyNames, Type[] types) throws CallbackException {		return false;	}	public boolean onFlushDirty(Object entity, Serializable id,			Object[] currentState, Object[] previousState,			String[] propertyNames, Type[] types) throws CallbackException {		if ( entity instanceof Document ) {			currentState[2] = Calendar.getInstance();			return true;		}		else {			return false;		}	}	public boolean onSave(Object entity, Serializable id, Object[] state,			String[] propertyNames, Type[] types) throws CallbackException {		if ( entity instanceof Document ) {			state[3] = state[2] = Calendar.getInstance();			return true;		}		else {			return false;		}	}	public void onDelete(Object entity, Serializable id, Object[] state,			String[] propertyNames, Type[] types) throws CallbackException {	}	public void preFlush(Iterator entities) throws CallbackException {	}	public void postFlush(Iterator entities) throws CallbackException {	}	public Boolean isTransient(Object entity) {		return null;	}	public int[] findDirty(Object entity, Serializable id,			Object[] currentState, Object[] previousState,			String[] propertyNames, Type[] types) {		return null;	}	public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException {		return null;	}	public String getEntityName(Object object) throws CallbackException {		return null;	}	public Object getEntity(String entityName, Serializable id)			throws CallbackException {		return null;	}	public void afterTransactionBegin(Transaction tx) {}	public void afterTransactionCompletion(Transaction tx) {}	public void beforeTransactionCompletion(Transaction tx) {}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?