Hey,
When discussing this before, there were some doubts about its actual
usefulness in non-testing, real-world code. E.g. you'd typically
interact with multiple DAOs/repositories etc. and would have to
somehow pass the session to each of them.
One other thought is that inTransaction() should allow to return a result value.
--Gunnar
Am Do., 20. Dez. 2018 um 17:02 Uhr schrieb Steve Ebersole <steve(a)hibernate.org>:
In tests we find our `#inSession` and `#inTransaction` methods very
useful. Which got me thinking that maybe we should support these on
SessionFactory directly:
public interface SessionFactory ... {
...
void inSession(Consumer<Session> action);
void inTransaction(Consumer<Session> action);
void inTransaction(Session session, Consumer<Session> action);
}
and maybe even:
public interface Session ... {
void inTransaction(Consumer<Session> action);
}
Objections?
_______________________________________________
hibernate-dev mailing list
hibernate-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev