Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:58:59+00:00 2026-06-13T06:58:59+00:00

I have an application that does some batch jobs using MySQL and, via REST,

  • 0

I have an application that does some batch jobs using MySQL and, via REST, Neo4j server version.

I can’t figure out how to make them to work together correctly: I can get to make work both of them, but not at the same time. The posts I’ve found around are not specific to the server version of Neo4j, and maybe that’s where the problem is, since everything else seems ok to me.

My configuration:

JpaConfig

@Configuration
@EnableTransactionManagement(order=Ordered.HIGHEST_PRECEDENCE)
@PropertySource("META-INF/database.properties")
@ImportResource("classpath*:META-INF/repository.xml")
public class JpaConfig {
@Autowired
Environment env;

@Bean(destroyMethod = "close")
public DataSource dataSource() {
    DataSource dataSource = new DataSource();
    dataSource.setDriverClassName(env.getProperty("database.driverClassName"));
    dataSource.setUrl(env.getProperty("database.url"));
    dataSource.setUsername(env.getProperty("database.username"));
    dataSource.setPassword(env.getProperty("database.password"));
    dataSource.setTestOnBorrow(true);
    dataSource.setTestOnReturn(true);
    dataSource.setTestWhileIdle(true);
    dataSource.setTimeBetweenEvictionRunsMillis(1800000);
    dataSource.setNumTestsPerEvictionRun(3);
    dataSource.setMinEvictableIdleTimeMillis(1800000);
    dataSource.setValidationQuery("SELECT 1");
    return dataSource;
}

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactory.setDataSource(dataSource());
    entityManagerFactory.setPackagesToScan("it.smartblue.mcba.domain");
    entityManagerFactory.setJpaDialect(new HibernateJpaDialect());
    Map<String, String> jpaProperties = new HashMap<>();
    jpaProperties.put("hibernate.connection.charSet", "UTF-8");
    jpaProperties.put("hibernate.ejb.naming_strategy", "org.hibernate.cfg.EJB3NamingStrategy");
    jpaProperties.put("hibernate.bytecode.provider", "javassist");
    jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");
    entityManagerFactory.setJpaPropertyMap(jpaProperties);
    entityManagerFactory.setPersistenceProvider(new HibernatePersistence());
    return entityManagerFactory;
}

@Bean
public PlatformTransactionManager transactionManager() {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return transactionManager;
}

@Bean
public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
    return new PersistenceExceptionTranslationPostProcessor();
}
}

Neo4j.xml

<!-- neo4j configuration -->
<neo4j:config graphDatabaseService="graphDatabaseService" entityManagerFactory="entityManagerFactory"/>
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
    <constructor-arg index="0" value="http://192.168.11.186:7474/db/data" />
</bean>
<neo4j:repositories base-package="it.smartblue.mcba.neo4j.repository" />

With this configuration Mysql works perfectly, but Neo4j doesn’t save any property to the nodes it creates.

If I remove the attribute entityManagerFactory="entityManagerFactory" Neo4j works, but I can’t write to MySQL.

My services methods are annotated with @Transactional or @Neo4jTransactional, not both at the same time.

Inside the class org.springframework.data.neo4j.rest.SpringRestGraphDatabase for the graphDatabaseService bean I’ve found:

@Override
public Transaction beginTx() {
    // return super.beginTx();
    return new NullTransaction();
}

@Override
public TransactionManager getTxManager() {
    return new NullTransactionManager();
}

Maybe it’s a work in progress? Or maybe I miss something…

I’m using Spring 3.1.2, Hibernate 4.1.4. Here is part of my pom.xml.

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.2.0.RC1</version>
</dependency> 
  <!-- Neo4j dependencies -->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j</artifactId>
        <version>2.1.0.RC4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j-rest</artifactId>
        <version>2.1.0.RC4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j-cross-store</artifactId>
        <version>2.1.0.RC4</version>
    </dependency>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:59:00+00:00Added an answer on June 13, 2026 at 6:59 am

    Finally I made it.

    Instead of having two different transactionManagers, now I have only one ChainedTransactionManager.

    I removed the transactionManager bean from JpaConfig and the neo4j.xml file, and added the following Neo4jConfig

    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.data.neo4j.config.EnableNeo4jRepositories;
    import org.springframework.data.neo4j.config.JtaTransactionManagerFactoryBean;
    import org.springframework.data.neo4j.config.Neo4jConfiguration;
    import org.springframework.data.neo4j.rest.SpringRestGraphDatabase;
    import org.springframework.data.neo4j.transaction.ChainedTransactionManager;
    import org.springframework.orm.jpa.JpaTransactionManager;
    import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
    import org.springframework.transaction.PlatformTransactionManager;
    
    @EnableNeo4jRepositories(basePackages = { "it.smartblue.mcba.neo4j.repository" })
    @Configuration
    public class Neo4jConfig extends Neo4jConfiguration {
    
        @Autowired
        LocalContainerEntityManagerFactoryBean entityManagerFactory;
    
        @Bean
        public SpringRestGraphDatabase graphDatabaseService() {
            return new SpringRestGraphDatabase("http://192.168.11.186:7474/db/data");
        }
    
        @Override
        @Bean(name = "transactionManager")
        public PlatformTransactionManager neo4jTransactionManager() throws Exception {
            return new ChainedTransactionManager(new JpaTransactionManager(entityManagerFactory.getObject()),
                    new JtaTransactionManagerFactoryBean(graphDatabaseService()).getObject());
        }
    }
    

    Now I have to use on my methods only the @Transactional annotation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that does some image processing using rmagick and imagemagick. This
I have been using Titanium for an Android application that does some microblogging through
I have a web application build on PHP that (does some processing and) displays
I have a need to write a GTK application in C that does some
We have built a web application that accepts SOAP messages, does some processing, calls
I have a Winforms application that does some hefty database work. It does a
I have written a .net winforms application that does some heavy processing and slows
I have an application that does some data processing, then notifies the user in
I have a Windows application that does some calculations and is called from command
I have a program that does batch processing on some drawings. One of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.