Announcement Announcement Module
Collapse
No announcement yet.
Transactional context with @Transactional + repository.save()? (Neo4j) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transactional context with @Transactional + repository.save()? (Neo4j)

    I have a method which is marked with @Transactional and needs to save entities at several points.

    I also have spring managed repositories created for them and now I am wondering if each save method will create another transaction (because they can work without explicitly declaring a transaction context) or if they are aware of the @Transaction annotation and simply participate in them without invoking another transaction.

    Code:
    @Transactional
    void saveInTransaction() {
    
       NodeEntity ne = new NodeEntity();
    
       nodeEntityRepository.save(ne); // is this a seperate transaction?
       neo4jTemplate.save(ne) // whats the difference to the spring data created repository methods?
    
       ne.SetSomeValue("foo");
       nodeEntityRepository.save(ne);
    
    }

  • #2
    Chris,

    Neo4jTemplate is the concrete implementation that everything else relies on - including the generated repositories which delegate to it.

    For transactions, you need to control that on the application level, either explicitly or with annotations. We do not start transactions on your behalf. In your concrete example, the outcome of that entire method is _one_ atomic operation.

    Regards,

    Lasse

    Comment


    • #3
      Great, thanks for clearing that up.

      Comment

      Working...
      X