⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gaodbinterceptor.java

📁 本代码是在eclipse下开发hibernate的典型实例
💻 JAVA
字号:
package com.jgao.hql.test.business.others;


public class GaodbInterceptor{ //implements Interceptor, Serializable {

//    private int updates;
//    private int creates;
//
//    public void onDelete(Object entity,
//                         Serializable id,
//                         Object[] state,
//                         String[] propertyNames,
//                         Type[] types) {
//        // do nothing
//    }
//
//    public boolean onFlushDirty(Object entity, 
//                                Serializable id, 
//                                Object[] currentState,
//                                Object[] previousState,
//                                String[] propertyNames,
//                                Type[] types) {
//
//        if ( entity instanceof Gaodb ) {
//            updates++;
//            for ( int i=0; i < propertyNames.length; i++ ) {
//                if ( "lastUpdateTimestamp".equals( propertyNames[i] ) ) {
//                    currentState[i] = new Date();
//                    return true;
//                }
//            }
//        }
//        return false;
//    }
//
//    public boolean onLoad(Object entity, 
//                          Serializable id,
//                          Object[] state,
//                          String[] propertyNames,
//                          Type[] types) {
//        return false;
//    }
//
//    public boolean onSave(Object entity,
//                          Serializable id,
//                          Object[] state,
//                          String[] propertyNames,
//                          Type[] types) {
//        
//        if ( entity instanceof Auditable ) {
//            creates++;
//            for ( int i=0; i<propertyNames.length; i++ ) {
//                if ( "createTimestamp".equals( propertyNames[i] ) ) {
//                    state[i] = new Date();
//                    return true;
//                }
//            }
//        }
//        return false;
//    }
//
//    public void postFlush(Iterator entities) {
//        System.out.println("Creations: " + creates + ", Updates: " + updates);
//    }
//
//    public void preFlush(Iterator entities) {
//        updates=0;
//        creates=0;
//    }
//    
//    public void isUnsaved(Iterator entities) {
//        //
//    }   
//    
////    public boolean findDirty(Object entity, 
////            Serializable id, 
////            Object[] currentState,
////            Object[] previousState,
////            String[] propertyNames,
////            Type[] types) {
////        //
////    }

}

⌨️ 快捷键说明

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