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 7049007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:57:37+00:00 2026-05-28T02:57:37+00:00

I’m using the simple object/graph mapping in Spring Data Neo4j 2.0, where I perform

  • 0

I’m using the simple object/graph mapping in Spring Data Neo4j 2.0, where I perform persistence operations using the Spring Data repository framework. I’m working with the repositories rather than working with the Neo4jTemplate. I inject the repositories into my Spring Web MVC controllers, and the controllers call the repos directly. (No intermediate service layer–my operations are generally CRUDs and finder queries.)

When I do read operations, there are no issues. But when I do write operations, I get “NotInTransactionException”. My understanding is that read ops in Neo4j don’t require transactions, but write ops do.

What’s the best way to get transactions into the picture here, assuming I want to stick with the simple OGM? I’m wanting to use @Transactional, but putting that on the various repository interfaces doesn’t work. If I introduce an intermediate service tier in between the controllers and the repositories and then annotate the service beans with @Transactional, then it works, but I’m wondering whether there’s a simpler way to do it. Without Spring Data, I’d typically have access to the DAO (repository) implementations, so I’d be able to annotate the concrete DAOs with @Transactional if I wanted to avoid a pass-through service tier. With Spring Data the repos are dynamically generated so that doesn’t appear to be an option.

  • 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-05-28T02:57:38+00:00Added an answer on May 28, 2026 at 2:57 am

    First, note that having transactional DAOs is not generally a good practice. But if you don’t have a service layer, then let it be on the DAOs.

    Then, you can enable declarative transactions. Here’s how I did it:

    First, define an annotation called @GraphTransactional:

    @Retention(RetentionPolicy.RUNTIME)
    @Transactional("neo4jTransactionManager")
    public @interface GraphTransactional {
    
    }
    

    Update: spring-data-neo4j have added such an annotation, so you can reuse it instead of creating a new one: @Neo4jTransactional

    Then, in applicationContext.xml, have the following (where neo4jdb is your EmbeddedGraphDatabase):

    <bean id="neo4jTransactionManagerService"
        class="org.neo4j.kernel.impl.transaction.SpringTransactionManager">
        <constructor-arg ref="neo4jdb" />
    </bean>
    <bean id="neo4jUserTransactionService" class="org.neo4j.kernel.impl.transaction.UserTransactionImpl">
        <constructor-arg ref="neo4jdb" />
    </bean>
    
    <bean id="neo4jTransactionManager"
        class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager" ref="neo4jTransactionManagerService" />
        <property name="userTransaction" ref="neo4jUserTransactionService" />
    </bean>
    
    <tx:annotation-driven transaction-manager="neo4jTransactionManager" />
    

    Have in mind that if you use another transaction manager as well, you’d have to specify order="2" for this annotation-driven definition, and also have in mind that you won’t have two-phase commit if you have one method that is declared to be both sql and neo4j transactional.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Seemingly simple, but I cannot find anything relevant on the web. What is the
We're building an app, our first using Rails 3, and we're having to build

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.