I need to implements Threads for running some processes in my Java App with Spring and I'm using @Transactional to manage the Hibernate Transaction and commit the changes to the DB.
The issue is that when I use @Transactional in the threads, I get illegally attempted to associate a proxy with two open Sessions
I'm using @Transactional in the main thread (where I'm saving the objects in the database) and then call Future
to execute the threads
where I use @Transactional to recover and update the objects saved in the main thread, but I get the error mentioned above.
How is this suppose to work?
I tried to different flows and sending the IDs instead of the object to the threads, but in that way I get null from the database.