Use both neo4j and postgres in same project


I use sdn rx library and i have a postgres database also, i want to know if i can use the 2 db in the same project ?

Thank you

Yes you can, do you have any specific questions about it? I just wrote a python script that connects to Postgres, reads all the data from my Postgres database and wrote it to Neo4j without any issues.

Yes using both complementary to each other is perfectly ok.

I have in a service with two transactional operations, the first with a neo4j and the second with postgres like this :

alert.setEndDate(new Timestamp(receivedAlert.getTimestamp()*1000));;

addAlertLabel(alert) will add a label to a node in the neo4j graph will save an entity in the postgres db

the operation with neo4j is good but the seconde operation (the save in postgres) does not work (i have no error but it don't find the entity in the db)

I use the sdn rx library, before when i used neo4j-java-driver it worked well.

Do you use @Transactional on your methods? This should make both transaction managers (Neo4j and JPA(?)) aware of an ongoing Spring transaction and they will share their state information.

yes i tried @Transactional i have this error :

Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.transaction.TransactionManager' available: expected single matching bean but found 2: transactionManager,reactiveTransactionManager

@Transactional from springframework transaction or javax.transaction ?

Sorry for the delayed answer:
We checked back and it is not as simple as I thought. You would need to declare a third TransactionManager. To be more precise it should be a (named) ChainedTransactionManager that will take the JPA/JDBC and Neo4j transaction manager. You will then have to declare this transaction manager in the annotation like @Transactional("myChainedTxManager").