Code example for ProxyFactory

Methods: getProxy, addAdvice, setInterfaces, setTarget

0
     */ 
    public Session getSession() { 
 
        Session unwrapped = SessionFactoryUtils.getSession(factory, false); 
 
        ProxyFactory proxyFactory = new ProxyFactory(); 
        proxyFactory.setInterfaces(new Class[]{ 
            Session.class, 
            org.hibernate.classic.Session.class, 
            org.hibernate.event.EventSource.class}); 
        proxyFactory.setTarget(unwrapped); 
        proxyFactory.addAdvice(0, this); 
        return (Session) proxyFactory.getProxy(); 
 
    } 
 
    /** 
     * Wraps all invocations to Session to prevent certain usages. 
     * Note: {@link QueryBuilder} may unwrap the session in certain 
     * cases.