if (checkHibernateEjb(classLoader))
return;
LOGGER.debug("Override org.hibernate.cfg.Configuration#buildSessionFactory to create a SessionFactoryProxy proxy.");
CtClass serviceRegistryClass = classPool.makeClass("org.hibernate.service.ServiceRegistry");
CtMethod oldMethod = clazz.getDeclaredMethod("buildSessionFactory", new CtClass[]{serviceRegistryClass});
oldMethod.setName("_buildSessionFactory");
CtMethod newMethod = CtNewMethod.make(
"public org.hibernate.SessionFactory buildSessionFactory(org.hibernate.service.ServiceRegistry serviceRegistry) throws org.hibernate.HibernateException {" +