protected Session createSessionProxy ( Session session ) { Class < ? > [ ] sessionIfcs ; Class < ? > mainIfc = Session . class ; if ( session instanceof EventSource ) { sessionIfcs = new Class [ ] { mainIfc , EventSource . class } ; } else if ( session instanceof SessionImplementor ) { sessionIfcs = new Class [ ] { mainIfc , SessionImplementor . class } ; } else { sessionIfcs = new Class [ ] { mainIfc } ; } return ( Session ) Proxy . newProxyInstance ( session . getClass ( ) . getClassLoader ( ) , sessionIfcs , new CloseSuppressingInvocationHandler ( session ) ) ; }
Create a close - suppressing proxy for the given Hibernate Session . The proxy also prepares returned Query and Criteria objects .