Hi All,

It would be good if the DataContext class had a method:

  public static boolean hasThreadDataContext() {
      return (threadDataContext.get() != null);
  }


I am working with a scenario where a third party library is making
direct calls to Cayenne service methods. If I can test whether the
thread local dataContext is not defined I can then initialize it.

Currently I have hacked the DataContext class as a work around:

   public static DataContext getThreadDataContext() throws
IllegalStateException {
       DataContext dc = (DataContext) threadDataContext.get();
       if (dc == null) {
           dc = createDataContext();
           threadDataContext.set(dc);
       }

       return dc;
   }


regards Malcolm Edgar

Reply via email to