Hi all,

we have some issues with transactions in Virtuoso and Jena driver (or JDBC one).

Here is a typical use case for us :

1) open transaction
2) insert data into one named graph
3) insert data into another named graph
4) commit changes

Of course, in case of error, we need a global rollback.

As we don't see how to express this with Jena API only (as in
http://docs.openlinksw.com/virtuoso/rdfnativestorageproviders.html#rdfnativestorageprovidersjenaexamples6
), we tried to use JDBC driver.

Here is an extract of our Spring 2.5.6 configuration :

<!-- Transaction management by annotations (@Transactional) -->
<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/>

<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
 <property name="userTransaction" ref="jotm"/>
</bean>

<bean id="dataSource" class="virtuoso.jdbc3.VirtuosoXADataSource">
 <property name="serverName" value="localhost" />
 <property name="portNumber" value="1111" />
 <property name="user" value="dba" />
 <property name="password" value="dba" />
 <property name="charset" value="UTF8" />
</bean>

Now we can express something like that :

import org.springframework.jdbc.core.JdbcTemplate;

@Transactional(rollbackFor={RuntimeException.class})
public static void executeRequests() throws Exception {

   DataSource dataSource = (DataSource) new
ClassPathXmlApplicationContext("applicationContext.xml").getBean("dataSource")

   /* some code here */

   JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
   jdbcTemplate.execute("sparql " + validInsertQuery);
   jdbcTemplate.execute("sparql " + insertQueryWithError);
}

The expected result is a global rollback during the second execution
but actually, the first insert is really committed.

Has anybody experienced such a use case ? Was anybody able to do it in
pure Jena ?

Regards,

Alexandre.

Reply via email to