this.CreateContext(); or this.getContext().getSession().createContext();

0
Hi all, I've got a Java action with the following code: @Override public IMendixObject executeAction() throws Exception { // BEGIN USER CODE //Create own context IContext ct = this.getContext().getSession().createContext(); //Start own db transaction ct.startTransaction(); //Create new object FlagSemaphoreSE newFlagSemaphoreSE = new FlagSemaphoreSE(ct); //Set data type on object newFlagSemaphoreSE.setDataType(datatype); //Commit object newFlagSemaphoreSE.commit(); //Close transaction ct.endTransaction(); //Return the object return newFlagSemaphoreSE.getMendixObject(); // END USER CODE } However I don't understand what the difference is between IContext ct = this.getContext().getSession().createContext(); and IContext ct = this.createContext(); The latter generates errors: als ik alleen createcontext doe krijg ik dit com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: com.mendix.core.CoreRuntimeException: com.mendix.core.CoreRuntimeException: com.mendix.core.CoreRuntimeException: Exception occurred in action '{"type":"CreateAction","entityName":"EISData.FlagSemaphoreSE"}', all database changes executed by this action were rolled back at EISData.SUB_Check_FlagSemaphore (JavaAction : 'Call 'JA_CreateFlagSemaphoreSEAndCommit'') at EISData.WSP_TRAFROUT00_ProcessWS (SubMicroflow : 'Call 'SUB_Check_FlagSemaphore'') What I expect as behavior: When a flow is triggered a retrieve on DB is performed to check if the "FlagSemaphoreSE" object exists, if it exists the microflow is ended, if not a submicroflow (SUBCheckFlagSemaphore) is triggered, creates one and commits this to the db (which includes a java action mentioned above). Then the rest of the first microflow is performed. This should prevent multiple runs of the same microflow simultaneous. I know it's not 100% proof, but sufficiƫnt for what I'm trying to achieve. The question is, what is the difference between the this.CreateContext(); and this.getContext().getSession().createContext(); With kind regards, Stephan
asked
1 answers
0

There is no difference between these 2, they both create a new context for the session attached to the current context of the (java) action that is being executed. Btw, won't setting 'Concurrent execution > disallow' to true help you?

answered