[email protected] wrote:
Bob,

Firs, thanks for your response.

Yes Bob, the approval is another task in the system and happens hours or days 
later.


Right, so this will create a long running transaction and depending on your database might create a lock on the entire table and you would only be able to handle one request at a time for all users accessing that table.

How about committing the transaction (once the upload is complete), and later if the validation fails, delete (undo) the changes. The tradeoff is that you will have more work to do.


I would like
-------------
May be there is a way to manually create a transaction covering everything going on in the onPost() method, in this way the reads (check) and writes (act) would preserve the business rules, no matter how many windows or sessions could be
trying to do it at once.


If you want to manage your own transactions with Cayenne, see this page: http://cayenne.apache.org/doc20/understanding-transactions.html

Also keep in mind that you can create a custom DataContextFilter and bypass the filter for specific requests. This way you are in control of creating the DataContext:


public class MyDataContextFilter extends DataContextFilter {

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {

    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String resourcePath = ClickUtils.getResourcePath(httpRequest);
    if (resourcePath.endsWith("/uploadDoc.htm")) {

      // Bypass this filter
      chain.doFilter(request, response);
    } else {

      // Perform default operation
      super.doFilter(request, response, chain);
    }
}

Hope this helps.

kind regards

bob

Reply via email to