Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-17-2021 08:34 AM
I am drafting a Java procedure to plug in to Neo4j. The procedure is in a file and a class ("Class 1"). To make things more organized, I am moving certain functions into separate classes (Class 2, Class 3, etc.) in the same src folder. Class 2 works fine, but the problem I am having with Class 3 is that it requires I invoke graphdatabaseservice.Transaction.CreateNode and I think the problem is that perhaps you can't invoke "Transaction" in a class that is not itself a procedure.
(A) Is that true?
(B) Is there a way around this limitation? I'd like to try and keep each class as small and streamlined as possible. I am assuming (perhaps incorrectly) that I can't make Class 3 a Procedure, because I am not trying to create two procedures. I am trying to just move some of the functionality from Class 1 to Class 3.
09-28-2021 04:22 PM
You can pass the Transaction to the other class via a constructor or method parameter.
And yes in general it's good to separate the procedure class from the bit actually doing the work, so you can also test it independently.
09-29-2021 05:16 AM
Thanks. I managed to get there eventually, but it took me some time. I posted the question and answer to the question on Stack Overflow as well, so people should be able to benefit from that.
I have a separate question on junit tests I will post as well.
All the sessions of the conference are now available online