Neo4j-Jdbc with spring transaction not working
<p>I am using neo4j-jdbc-2.3.2 with Spring 4+. For CRUD i am using JDBCTemplate.</p>

<p>I am facing two challenges</p>

<ol>
<li>Transactions are not working. Throwing Checked or Unchecked exception do not rollback the transaction and persists data in Neo4j</li>
<li>JDBCTemplate has a feature of returning auto Generated ID using KeyHolder class. This is not working with Neo4j. Its giving me Null Pointer.</li>
</ol>

<p>Here is a small test case</p>

<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Neo4jJdbcSpike.Config.class })
@Transactional
@Rollback(false)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class Neo4jJdbcSpike {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Test
    public void transactionManagementNotWorkingTest() {
        String cypher = "create (a:Person { name: ?})";
        jdbcTemplate.update(cypher, new Object[] { "Foo" });
        throw new IllegalStateException("This will not rollback trnsaction");
    }

    @Test
    public void transactionManagementNotWorkingCheckedExceptioTest() throws CheckedException {
        String cypher = "create (a:Person { name: ?})";
        jdbcTemplate.update(cypher, new Object[] { "Bar" });
        throw new CheckedException();
    }

    @Test
    public void getGeneratedGraphIDTest() throws CheckedException {
        String cypher = "create (a:Person { name: ?})";
        KeyHolder holder = new GeneratedKeyHolder();
        PreparedStatementCreator psc = new PreparedStatementCreator() {

            @Override
            public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
                PreparedStatement ps = con.prepareStatement(cypher, Statement.RETURN_GENERATED_KEYS);
                ps.setString(1, "Bar");
                return ps;
            }
        };
        jdbcTemplate.update(psc, holder);
        Assert.assertNotNull(holder.getKey());
        Assert.assertTrue(holder.getKey().longValue() &gt; 0L);
    }

    public static class CheckedException extends Exception {

    }

    @Configuration
    @Import(TestConfig.class)
    @EnableTransactionManagement
    static class Config {

        @Bean
        public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
            return new PropertySourcesPlaceholderConfigurer();
        }

        @Bean
        public DataSource dataSource() {
            return new DriverManagerDataSource("jdbc:neo4j://localhost:7474", "neo4j", "passw0rd");
        }

        @Bean
        public JdbcTemplate jdbcTemplate(DataSource dataSource) {
            return new JdbcTemplate(dataSource);
        }

        @Bean
        public DataSourceTransactionManager txManager(DataSource dataSource) {
            return new DataSourceTransactionManager(dataSource);
        }

    }

}
</code></pre>

<p>NOTE: All of the test cases are failing...
Thanks in Advance....</p>