Local Transaction mode

Hi,

I know that if I use the function of TXMLObjectAccessor query( TQuery query, int quantity) , I need use Local Transaction Mode,

But How to use this mode? Please give me an example from the begnning of connection,thx

Hi there,

1) You create a TConnection thus:
TConnection tcon = TConnectionFactory.getInstance().newConnection (DATABASE_URL) ;

2) Switch to local transaction mode thus:
TLocalTransaction tloc = tcon.useLocalTransactionMode () ;

3) Perform any updates using TXMLObjectAccessor then when you want to commit, use the TLocalTransaction object thus:
tloc.commit();

4) Revert back to autocommit mode using:

tcon.useAutoCommitMode();

hi,

please check either of the examples provided along with the api:

/help/inoapi/listings/hello/ProcessXMLGreeting.java

or

several other java files in

/help/inoapi/listings/jazz


best regards,
andreas f.

And if another thread access the same information before of my commit?Is this the sense of LTM, that is a take a copy of the data and then i update the db, is it correct?

@nto

I don’t think I understand your question. Could you please rephrase your question?

Probably i don’t understand propertly the essence of local transaction mode…can u explain it to me in a few words?

Local Transaction Mode means that you operate within a session context. With this a session is opened, and any updates (inserts, modifications and deletions) are not automatically committed to the database. This means that you can control if these update(s) are to be committed or rolled back (by using commit() and rollback() methods of the TLocalTransaction interface).

This is orthogonal to Auto Commit Mode which is the default with the Tamino for Java API. In this mode there is no session context so any updates are automatically committed so there is no commit or rollback in this scenario.

Now it’s more clear.
What i’m wordering is that if i performe update insert etc… in a ltm and another person accesses (before my commit) the data i’m manipulating in ltm, what’s happen?
When i use ltm a put a read lock in the db?
How does the lock\unlock mechanism work in Tamino?

Brgs
@nto

This is best described in the documentation. Following the link “X-Machine Programming” from the Tamino Documentation. Click on the link “Requests using X-Machine Commands” and look under the heading “Transaction Related Commands”.

Thx a lot Stuart Fyffe-Collins.
Brgs
@nto