@@ -0,0 +1,1663 @@
+package cronapi.database;%0A%0Aimport java.lang.reflect.InvocationTargetException;%0Aimport java.lang.reflect.Method;%0A%0Aimport org.eclipse.persistence.descriptors.DescriptorQueryManager;%0A%0Aimport javassist.util.proxy.MethodHandler;%0Aimport javassist.util.proxy.ProxyFactory;%0Aimport javassist.util.proxy.ProxyObject;%0A%0Apublic class CronappDescriptorQueryManager %7B%0A  %0A  private static ThreadLocal%3CBoolean%3E DISABLED = new ThreadLocal%3C%3E();%0A  %0A  public static void disableMultitenant() %7B%0A    DISABLED.set(true);%0A  %7D%0A  %0A  public static void enableMultitenant() %7B%0A    DISABLED.remove();%0A  %7D%0A  %0A  public static boolean needProxy(DescriptorQueryManager obj) %7B%0A    if(obj == null)%0A      return false;%0A    %0A    return !obj.getClass().getName().contains(%22jvst%22);%0A  %7D%0A  %0A  public static DescriptorQueryManager build(final DescriptorQueryManager toWrap)%0A          throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException %7B%0A    %0A    ProxyFactory factory = new ProxyFactory();%0A    factory.setSuperclass(DescriptorQueryManager.class);%0A    Class clazz = factory.createClass();%0A    MethodHandler handler = new MethodHandler() %7B%0A      %0A      @Override%0A      public Object invoke(Object self, Method overridden, Method forwarder, Object%5B%5D args) throws Throwable %7B%0A        if(overridden.getName().equals(%22getAdditionalJoinExpression%22)) %7B%0A          if(DISABLED.get() != null && DISABLED.get()) %7B%0A            return null;%0A          %7D%0A        %7D%0A        return overridden.invoke(toWrap, args);%0A      %7D%0A    %7D;%0A    Object instance = clazz.newInstance();%0A    ((ProxyObject)instance).setHandler(handler);%0A    return (DescriptorQueryManager)instance;%0A  %7D%0A%7D%0A

Suporte a desabilitar multitenant