Quantcast
Channel: Mendix Forum Questions
Viewing all articles
Browse latest Browse all 80923

Commit Object instantly after changing the value in Java action

$
0
0

Hi All,

I am working on a requirement where we have to create unique reference number (customized - Example - XXXX01234). Problem is, when we use the latest used number in DB, sometimes we can get the same number for different transactions as the commit is not getting completed until all the microflows complete running.

I have decided to do these things in Java action and it doesn't help me either. Below is my Java code. Can anyone help me if we can do commit instantly in DB using Java action.

Appreciate your help.

Java Code:

Sequence ProductSequenceObj = this.ProductParameter1.getProduct_Sequence().get(0);
        switch (ParameterParameter1) 
        {
        case Quote:            
            newSequenceNo = ProductSequenceObj.getLatestAssignedNumberQuotes()+1;
            ProductSequenceObj.setLatestAssignedNumberQuotes(newSequenceNo);            
            ProductSequenceObj.commit();
            break;            
            
        default:
            newSequenceNo = ProductSequenceObj.getLatestAssignedNumberPolicies()+1;
            ProductSequenceObj.setLatestAssignedNumberPolicies(newSequenceNo);
            Core.commitWithoutEvents(getContext(), seQuenceEntity);
            ProductSequenceObj.commit();
            break;
        }
        return (long) newSequenceNo;

Thanks,

Nags


Viewing all articles
Browse latest Browse all 80923

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>