Does Java have a using statement that can be used when opening a session in hibernate?
In C# it is something like:
using (var session = new Session()
Since Java 7 it does: http://blogs.oracle.com/darcy/entry/project_coin_updated_arm_spec
The syntax for the code in the question would be:
try (Session session = new Session()) { // do stuff }
Note that Session needs to implement AutoClosable or one of its (many) sub-interfaces.
Session