I am using simple-react.
Inside LazyFutureStream
I want to persist the entity .
LazyFutureStream.parallel(1,2,3,4,5)
.map(id -> {
try {
SessionFactory sessionFactory = Application.getHibernateBundle()
.getSessionFactory();
ManagedSessionContext.bind(sessionFactory.openSession());
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();
Model model = new Model(sessionFactory);
model.persist(id);
session.getTransaction().commit();
}
});
Is this correct ? Is there any way i can skip session factory creation for every thread .
ALSO in above I only want to fork but not join. Is that fine?