Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-10-2019 11:41 PM
How can I get the current session in a Neo4j SDN @Transactional method? e.g. if I want to run a query that is used only in one place and I do not want to make a separate method for it in a repository.
It seems that a SessionFactory must have a getCurrentSession method, but Neo4j SDN implementation does not provide such a method (See here).
Solved! Go to Solution.
09-16-2019 11:41 PM
Hello @shayantest2
If you inject the Session
, it will be aware of an ongoing transaction, i.e.
@Service
public class SomeService {
@Autowired // Though I rather prefer constructor injection, which works, too of course
Session session;
@Transactional
public void doSomething() {
// interact with session. The session is actually
// a proxy that knows about the Spring Transaction
}
}
09-13-2019 09:12 PM
Also, this may be necessary if the query is build at run-time and we do not know what exactly the query is so that we put in in an annotation.
09-16-2019 11:41 PM
Hello @shayantest2
If you inject the Session
, it will be aware of an ongoing transaction, i.e.
@Service
public class SomeService {
@Autowired // Though I rather prefer constructor injection, which works, too of course
Session session;
@Transactional
public void doSomething() {
// interact with session. The session is actually
// a proxy that knows about the Spring Transaction
}
}
All the sessions of the conference are now available online