have I been created in this transaction

Forums for specific tips, techniques and example code
Lorcan
Posts: 12
Joined: Thu Oct 07, 2010 8:51 am

have I been created in this transaction

Postby Lorcan » Mon Feb 24, 2014 8:56 am

Hi everyone,
Wonder if anyone can solve this conundrum....(in Jade 6)...

for the below piece of code, can you tell me how to code for the method hasBeenCreatedWithinThisBlock

Cheers for the time .. :)

lorcan




beginTransaction
create otherObject persistant;
commitTransaction

beginTransaction
create newObject persistant;

if newObject.hasBeenCreatedWithinThisBlock then
/> //this is true;
else
/> // this is false;
endif;

if otherObject.t.hasBeenCreatedWithinThisBlock then
/> //this is false
else
/> // this is true
endif;

commitTransaction

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: have I been created in this transaction

Postby murray » Mon Feb 24, 2014 10:31 am

What are you trying to achieve here?
1. You will need to define what "this block" actually means in a context that the proposed method will understand.
2. Also, you have explicitly coded to create these objects - why then do you need to check if you have just created them?
Murray (N.Z.)

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: have I been created in this transaction

Postby allistar » Mon Feb 24, 2014 11:23 am

This is extremely nasty, but it can be done by passing the object into a serverExecution method which returns "global.isValidObject" on the object. If the object has not been committed yet then this will return "false" on the server node. As I said this is nasty and will not be overly efficient.

A common pattern is to have a transient controller singleton which controls database transaction state handling as well as the execution of agents. This makes it easier to detect which objects have been created/modified/deleted in the current database transaction.


Return to “Tips and Techniques”

Who is online

Users browsing this forum: Bing [Bot] and 24 guests