Knowledgebase: MarkLogic Server
What does session.commit() do in XCC/J
08 July 2013 02:51 PM

Introduction

We have seen some confusion around the use of the commit() method when working with XCC/J or XCC .NET. In this article, we will walk through a scenario where exceptions are thrown if it is used in an unexpected way and we will discuss managing transactions in general. This article will attempt to give a clearer picture regarding how all the parts work in unison.

Walkthrough

We'll start by taking a look at the JavaDoc for XCC/J's Session.commit() at https://docs.marklogic.com/javadoc/xcc/com/marklogic/xcc/Session.html#commit()

Under the "Throws" heading, it states that you should expect to see an IllegalStateException if the TransactionMode is set to AUTO.

Consider the following code: