Being a new Servoy developer I’m not too happy with the default Servoy configuration not being based on transactions.javascript:emoticon(‘’)
Crying or Very sad
Probably this is a common subject and was already discussed somewhere but I was not able to find it at time being.
I would like to have a basic form template fully supporting transactions. Transactions must be obviously properly
opened and closed to maintain applications/solutions/modules consistent. Locks should be managed on record level.
My current idea is to:
Opening the solution setting autocommit off; then on each form:
onShow → startTransaction()
onRecordEditStart → acquireLock() at record level
when user ask to save changes (hit F6) commitTransaction() and startTransaction() again releasing all locks
two possibilities: 3a) onHide → rollbackTransaction() 3b) ask user onHide if commitTransaction() or rollbackTransaction()
Two questions:
a) Which is the event mapped to F6 ? If any, how to implement the need?
b) commitTransaction() and rollbackTransaction() automatically release all pending locks or should I do it on #3 ?
Are these good ideas?
If NO, what’s wrong with it?
Any other feeling this is a common need?
When I am not mistaking 3.0 offers you the option to uncheck autosave (don’t have it open so can’t tell you the correct naming).
This way you can wait until the user really approves of the input before saving/committing it. Just check it out…
Being a new Servoy developer I’m not too happy with the default Servoy configuration not being based on transactions.javascript:emoticon(‘’)
Crying or Very sad
Probably this is a common subject and was already discussed somewhere but I was not able to find it at time being.
I would like to have a basic form template fully supporting transactions. Transactions must be obviously properly
opened and closed to maintain applications/solutions/modules consistent. Locks should be managed on record level.
Ciao, Gianni
if you’re not on Servoy v3, you can use this tecnique:
disable the form (so user cannot edit it unless he clicks on a button with a method that enables it)
when the user clicks the button, he also starts the transaction.
From this point, you can use your model (set the lock etc.)
Tnks Jan for your answer but…it is bringing me back to my initial point…and it was the reason I submitted the question.
Let me explain:
OnRecordSave is started keying F6 for EACH record to be saved…In other words F6 is not mapped to one event but it is triggering many events…
If the current form is record view based it is working but if it is list or table view based it does NOT…
To manage transactions I need to have a central point to commit/rollback user transaction; to this (not available in 2.2.5) event I should map a method executing something like:
store all changes (this pseudo instruction is starting onRecordSave for each record)
commit or rollback transaction
release all locks
start a new transaction
Considering there is no single event mapped to F6 the only way I see to workaround this is to execute a pseudo-code just described after the last
onRecordSave but I found no way to do it…
I feel the transaction model I described is not really implementable in Servoy 2.2.5 and this is the reason I wrote the initial question on the forum…
Basically, imho, this has become a theoretical discussion. Start using 3.0, although in beta this should be no issue as long as you are developing… Or do I miss something?
the central point of rollback or commit can be onRecordSave
How do you know when to rollback or commit? Do you check data?
Most of the time rollback or commit are done when a user presses an Cancel or Save button.
The best thing is to start using 3.0 and just turn off auto save. So that you don’t start long transactions on the database. But only do that in mem (with a lock if needed)
IT2BE…Having seen some development environments before my basic point is: everything is theoretical until I find a reasonable way to solve it!
I told already I am new to Servoy…Still trying hard to remap my knowledge into a real Servoy solution…using a beta to develop does not seems to me the best option…because of potential pitfalls of a Beta product…hard on hard…
jcompagner…hitting F6 to save and THEN pushing a button to commit is not the best interface for the end user…
but…yes…using onrecordsave could be:
check before writing if all data are OK
if not return false (is this really working?)
if yes commit
release single lock (NOT all locks!)
start new transaction
I am not sure it will work with all types of forms…
I did not find in all documentation/forum I read up to now and in the previous answers that startTransaction() means also autoCommit=OFF…
To me:
save=doing real I/O to update database (INSERT/UPDATE/DELETE)
commit=ask db to confirm what saved before…rollback denying it…
Servoy is by default autosaving and autocommitting…
I was supposing based on the previous part of the discussion that a specific function to disable autoCommit was needed because startTransaction disable only autosave!
About locks:
If onRecordSave should be used as suggested before
If I should release locks manually
In a table view forms after updating many record user hits F6
Application can do many commits in onRecordSave events but it is not reasonable to release all locks in the OnRecordSave of the first record…
So eventually I need a releaseSingleLock()…
or…simply avoid a generic basic transaction model for now…
disable autosave is done through databasemanger.autosave=true/false (or what it was exactly called in 2.2)
this has nothing to do with databasemanager.startTransaction…
That last thing is a real database thing where you set auto commit to off and saves to the database just happen but only after you commit they are really saved (or not when rollback is called)
Autosave in 3.0 is just really enhanced so that really nothing is saved to the database and you can rollback in mem the data user types in. So nothing is sent to the database at all. This is much better for performance and fill in dialogs with a cancel/ok button. (Long)transactions should be avoided if possible.
But do you really want to aquirelocks on (complete) foundsets and then release them one by one? Why do you need locks at the first place what is your usecase?
onHide → directly rollbackTransaction()
or
ask user if do a commit or a rollback…
This BASIC model is not GENERIC because it is requiring a button on each form.
ReThinking this final solution I would only like saveData (F6) to be mapped to a method enabling to relocate action #3 to the keystroke instead of the button on the form.
Tnks again to who have contributed!
Ciao,
Gianni
P.S. By the way I tried to explore your suggestion and looked in databaseManager.propertiesandmethods in Servoy V2.2.5 but I did not find any property/method to disable autosave…