Hi Danny,

As you said getAutoCommit() is always true, so the commit() call is a 
no-op.

Is there any option to change AutoCommit value? 

I tried to call the setAutoCommit(false)  - But this function is 
implemented in such a way that it throws UnSupportedException.

Is there any way to change it., 

Regards,
Santhosh



Danny Sokolsky <[email protected]> 
Sent by: [email protected]
05/06/2009 12:18 AM
Please respond to
General Mark Logic Developer Discussion <[email protected]>


To
General Mark Logic Developer Discussion <[email protected]>
cc

Subject
RE: [MarkLogic Dev General] How to do Transaction       Management 
inMarklogic - reg.,






You cannot manage transaction in XCC per se.  Use MarkLogic Server to 
manage transactions by pushing them down to the server, as in Geert's 
example.  Each request to MarkLogic Server is a transaction, and will 
follow the transactional rules of MarkLogic (see the "Understanding 
Transactions" chapter in the Developer's Guide for some background).  In 
the XCC example below, there are two transactions:  the 
ContentFactory.newContent is one transaction, and the 
session.newAdhocQuery is another. 

The commit() call in your java code does not do what you think it does. In 
MarkLogic Server, getAutoCommit() is always true, so the commit() call is 
a no-op.

If you want to manage those as a single transaction, you have the 
following choices:

1) write java code to manage the transactions in your application 
(note--this might be hard)
2) push down the logic to XQuery and run it as a single transaction.

To expand on Geert's XQuery example, consider the following XQuery:

xdmp:node-replace(doc("/doc1.xml")/a/b, <b>goodbye</b>),
fn:error("woops")

In this case, the node replace will not happen, because an exception was 
thrown.  That exception simulates what would happen if a different update 
(to doc2 for example) throws an exception.

Hope that helps.

-Danny

-----Original Message-----
From: [email protected] [
mailto:[email protected]] On Behalf Of Geert Josten
Sent: Tuesday, May 05, 2009 7:36 AM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] How to do Transaction Management 
inMarklogic - reg.,

Hi Santhosh,

I am not very familiar with the XCC api itself, but I was told that there 
should be options to explicitly manage transactions. Perhaps there is XCC 
documentation on this matter? (Someone out there that could give a 
pointer?)

But my other approach is usefull here as well, I think. You are performing 
two separate function calls on the session object to perform different 
actions, but it should be possible to combine those in a single adhoc 
query call. You can use xdmp:filesystem-file to retrieve a document from 
file-system, so you won't need to use the 'insertContent' call. Try doing 
something like:

session.newAdhocQuery("
                 xdmp:document-insert(\"transaction1.xml\", 
xdmp:unquote(xdmp:filesystem-file(\"C:\\MarkLogic\\abc.xml\"))),
                 xdmp:document-insert(\"111.xml\", \"<a1> abc 111</a1>\")
"); 

Xdmp:filesystem-file returns a string, so you will need xdmp:unquote to 
parse that to XML nodes.

Kind regards,
Geert

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Santhosh Raj
> Sent: dinsdag 5 mei 2009 15:41
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] How to do Transaction 
> Management inMarklogic - reg.,
> 
> 
> Hi Geert, 
> 
>                         URI uri = new URI 
> ("xcc://admin:ad...@localhost:9000/training"); 
>                         ContentSource contentSource; 
>                         contentSource = 
> ContentSourceFactory.newContentSource(uri); 
>                         session = contentSource.newSession(); 
> 
>                         session = contentSource.newSession(); 
> 
>                         File file = new 
> File("C:\\MarkLogic\\abc.xml"); 
>                         InputStream is = new FileInputStream(file); 
>                         ContentCreateOptions createOptions = 
> new ContentCreateOptions(); 
>                         createOptions.setFormatBinary(); 
>                         Content content = 
> ContentFactory.newContent("transaction1.xml", is, createOptions); 
>                         session.insertContent(content); 
>                         System.out.println(" Document Inserted:" ); 
> 
>                         Request request = 
> session.newAdhocQuery("xdmp:document-insert(\"111.xml\" 
> ,\"<a1> abc 111</a1>\")                        ); 
> 
>                         ResultSequence rs = 
> session.submitRequest(request); 
>                         session.commit(); 
> 
> 
> In this example I want to execute 2 request in the same 
> transation, But it is not possible. 
> 
> 1) we can't do session.setAutoCommit(false)  - This will 
> throw unsupported exception. 
> 
> 2) Here eventhough if there is error in the second request 
> 
>         Request request = 
> session.newAdhocQuery("xdmp:document-insert(\"111.xml\" 
> ,\"<a1> abc 111</a1>\")                        ); 
> 
>    It still create the transaction1.xml in the marklogic 
> server. But acutally i do not what that to be created if any 
> one request fails. I guess there is no option to propagate 
> the transaction to both request. What is your idea? 
> 
> Thanks and Regards,
> Santhosh Rajasekaran
> 
> 
> 
> Geert Josten <[email protected]> 
> Sent by: [email protected] 
> 
> 05/05/2009 06:03 PM 
> Please respond to
> General Mark Logic Developer Discussion 
> <[email protected]>
> 
> To
> General Mark Logic Developer Discussion 
> <[email protected]> 
> cc
> Subject
> RE: [MarkLogic Dev General] How to do Transaction Management 
>       inMarklogic - reg.,
> 
> 
> 
> 
> 
> 
> Hi Santhosh,
> 
> There should be explicit transaction management functions in 
> the XCC library, but that requires a connection from Java or .Net.
> 
> You can also put the update statements in one Xquery and call 
> the Xquery through HTTP (or from XCC for the same matter). 
> Statements in one Xquery file are typically executed as one 
> transaction, and rolled back all together if any exception occurs.
> 
> (This, unless you explicitly use a semi-colon in the Xquery 
> main body. That ends the transaction for the first part of 
> the Xquery body, and opens a new one.)
> 
> Kind regards,
> Geert
> 
> >
> 
> 
> Drs. G.P.H. Josten
> Consultant
> 
> 
> http://www.daidalos.nl/ <http://www.daidalos.nl/> 
> Daidalos BV
> Source of Innovation
> Hoekeindsehof 1-4
> 2665 JZ Bleiswijk
> Tel.: +31 (0) 10 850 1200
> Fax: +31 (0) 10 850 1199
> http://www.daidalos.nl/ <http://www.daidalos.nl/> 
> KvK 27164984
> De informatie - verzonden in of met dit emailbericht - is 
> afkomstig van Daidalos BV en is uitsluitend bestemd voor de 
> geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, 
> verzoeken wij u het te verwijderen. Aan dit bericht kunnen 
> geen rechten worden ontleend.
> 
> 
> > From: [email protected]
> > [mailto:[email protected] 
> <mailto:[email protected]> ] On Behalf Of
> > Santhosh Raj
> > Sent: dinsdag 5 mei 2009 14:22
> > To: General Mark Logic Developer Discussion
> > Subject: [MarkLogic Dev General] How to do Transaction
> > Management in Marklogic - reg.,
> >
> >
> > Hi all,
> >
> >         Suppose I have 2 xml documents (doc1.xml , doc2.xml
> > ), I have to insert nodes to both documents.
> >
> > If i have inserted successfully in doc1.xml and if any error
> > occurs while inserting to doc2.xml, then i have to rollback
> > the node inserted in the doc1.xml
> >
> > How to manage it?
> >
> > Thnaks and Regards,
> > Santhosh Rajasekaran
> >
> > =====-----=====-----=====
> > Notice: The information contained in this e-mail message
> > and/or attachments to it may contain confidential or
> > privileged information. If you are not the intended
> > recipient, any dissemination, use, review, distribution,
> > printing or copying of the information contained in this
> > e-mail message and/or attachments to it are strictly
> > prohibited. If you have received this communication in error,
> > please notify us by reply e-mail or telephone and immediately
> > and permanently delete the message and any attachments. Thank you
> >
> >
> >
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general 
> <http://xqzone.com/mailman/listinfo/general> 
> 
> ForwardSourceID:NT0000AE12 
> 
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain 
> confidential or privileged information. If you are 
> not the intended recipient, any dissemination, use, 
> review, distribution, printing or copying of the 
> information contained in this e-mail message 
> and/or attachments to it are strictly prohibited. If 
> you have received this communication in error, 
> please notify us by reply e-mail or telephone and 
> immediately and permanently delete the message 
> and any attachments. Thank you
> 
> 
> _______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

ForwardSourceID:NT00002436 
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to