Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support transactions for Neo4j #18764

Open
adrianriesen opened this issue Jul 16, 2021 · 6 comments
Open

Support transactions for Neo4j #18764

adrianriesen opened this issue Jul 16, 2021 · 6 comments
Labels
area/neo4j kind/enhancement New feature or request

Comments

@adrianriesen
Copy link

Description

Currently the provided neo4j-java-driver does not participate in JTA transactions.

It would be helpful if one could span transactions across business logic methods which itself could contain multiple calls to different Neo4j data access methods.

Ideally this feature should be available in a JTA standard compliant fashion.

So if in the following example the repository methods would be implemented by using Neo4j / OGM, the business logic contained in the service method should be executed completely transactional.

@ApplicationScoped
public class BookServiceImpl implements BookService {

    private final BookRepository bookRepository;

    public BookServiceImpl(BookRepository bookRepository) {
        this.bookRepository = bookRepository;
    }

    @Transactional
    public Book clearAndSave(Book book) {
        this.bookRepository.deleteAll();
        return this.bookRepository.save(book);
    }
}

The implementation of such a Neo4j TX Manager and therefore transaction support for Neo4j would enable important capabilities when using Neo4j in Quarkus applications.

/cc @michael-simons

Implementation ideas

No response

@adrianriesen adrianriesen added the kind/enhancement New feature or request label Jul 16, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 16, 2021

/cc @michael-simons

@michael-simons
Copy link
Contributor

Thanks, Adrian.

After we spoke I had some thoughts.
for reasons I had to look at Hibernate-OGM. Different topic though (there are people using it and want to use a 4.x driver). While I evaluated the work necessary here, I came across. https://github.com/hibernate/hibernate-ogm/blob/main/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/remote/bolt/transaction/impl/BoltNeo4jResourceLocalTransactionCoordinator.java

which is actually quite usable.
I don’t want and I can’t support another OGM but I can see supporting a transaction coordinator similar to the one above. It needs to provide means to get a managed driver session so to say from it and your use case would work.

Also having such a managed driver session, we could pass it on to Neo4j-OGM (not the Hibernate one), which is an officially supported Neo4j library. @sandronm would that be of value to your project too?

@sandronm
Copy link

sandronm commented Jul 16, 2021 via email

@sandronm
Copy link

sandronm commented Feb 8, 2022

Hello!

Do you think there will be someday a support for @transactional annotation @michael-simons ?
In fact, I don't really care if it's a JTA transaction or not, but the problem is I just don't want to share between application layers the Transaction object and at the same time, I don't want to do all the logic in my repository layer.

But yes, for sure, it's just a "nice to have" in the end.

@michael-simons
Copy link
Contributor

Hey @sandronm I still have the branch in which I hook into Nayara JTA transaction and I played around with it after your comment to see if it still works with the new extension https://github.com/quarkiverse/quarkus-neo4j

In theory it would, and it would also be easier to add it into the extension, but the commentns of my general understanding of the JTA mechanism in place makes me wonder if its a good idea.

I would do it like yesterday if it was anything Spring TX Manager (that I know very well…)

@sandronm
Copy link

sandronm commented Feb 8, 2022

I hope somebody will be able to help you then ;-)
Unfortunately I'm not familiar neither with the JTA transaction mechanism behind the scene.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/neo4j kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants