triggerError(EntitManager entityManager){
Session session = entityManager.unwrap(Session.class); //done by functions the provide compatibility to Hibernate Core
// other code does something with the session and finally:
session.close();
boolean isOpen = entityManager.isOpen(); //true, should be falseif (isOpen){
entityManager.close(); // throws SessionException
}
}