@Test public void storeCatchesHibernateException() { when(this.session.save(this.event)).thenThrow(new HibernateException("failed")); this.store.store(this.event); Mockito.verify(this.session).close(); }
@Override public void store(AuditEvent event) { if (ACTION_IGNORED.contains(event.getAction())) { return; } Session session = this.sessionFactory.getSessionFactory().openSession(); try { Transaction t = session.beginTransaction(); t.begin(); session.save(event); t.commit(); } catch (HibernateException ex) { this.logger.error("Failed to save audit event [{}]: {}", event, ex.getMessage(), ex); } finally { session.close(); } }
HibernateAuditStore implements AuditStore { @Override public void store(AuditEvent event) { if (ACTION_IGNORED.contains(event.getAction())) { return; } Session session = this.sessionFactory.getSessionFactory().openSession(); try { Transaction t = session.beginTransaction(); t.begin(); session.save(event); t.commit(); } catch (HibernateException ex) { this.logger.error("Failed to save audit event [{}]: {}", event, ex.getMessage(), ex); } finally { session.close(); } } }
HibernateAuditStore implements AuditStore { @Override public void store(AuditEvent event) { if (ACTION_IGNORED.contains(event.getAction())) { return; } Session session = this.sessionFactory.getSessionFactory().openSession(); try { Transaction t = session.beginTransaction(); t.begin(); session.save(event); t.commit(); } catch (HibernateException ex) { this.logger.error("Failed to save audit event [{}]: {}", event, ex.getMessage(), ex); } finally { session.close(); } }  }
HibernateAuditStore implements AuditStore { @Override public void store(AuditEvent event) { if (ACTION_IGNORED.contains(event.getAction())) { return; } Session session = this.sessionFactory.getSessionFactory().openSession(); try { Transaction t = session.beginTransaction(); t.begin(); session.save(event); t.commit(); } catch (HibernateException ex) { this.logger.error("Failed to save audit event [{}]: {}", event, ex.getMessage(), ex); } finally { session.close(); } }  @Override void store(AuditEvent event); @Override List<AuditEvent> getEventsForEntity(DocumentReference entity); @Override List<AuditEvent> getEventsForEntity(DocumentReference entity, String type); @Override List<AuditEvent> getEventsForUser(User user); @Override List<AuditEvent> getEventsForUser(User user, String ip); @Override List<AuditEvent> getEventsForUser(User user, String ip, String type); @Override List<AuditEvent> getEvents(AuditEvent eventTemplate, Calendar fromTime, Calendar toTime, int start,
        int maxResults); @Override long countEventsForEntity(DocumentReference entity); @Override long countEventsForEntity(DocumentReference entity, String type); @Override long countEventsForUser(User user); @Override long countEventsForUser(User user, String ip); @Override long countEventsForUser(User user, String ip, String type); @Override long countEvents(AuditEvent eventTemplate, Calendar fromTime, Calendar toTime); }
HibernateAuditStore implements AuditStore { @Override public void store(AuditEvent event) { if (ACTION_IGNORED.contains(event.getAction())) { return; } Session session = this.sessionFactory.getSessionFactory().openSession(); try { Transaction t = session.beginTransaction(); t.begin(); session.save(event); t.commit(); } catch (HibernateException ex) { this.logger.error("Failed to save audit event [{}]: {}", event, ex.getMessage(), ex); } finally { session.close(); } }  @Override void store(AuditEvent event); @Override List<AuditEvent> getEventsForEntity(DocumentReference entity); @Override List<AuditEvent> getEventsForEntity(DocumentReference entity, String type); @Override List<AuditEvent> getEventsForUser(User user); @Override List<AuditEvent> getEventsForUser(User user, String ip); @Override List<AuditEvent> getEventsForUser(User user, String ip, String type); @Override List<AuditEvent> getEvents(AuditEvent eventTemplate, Calendar fromTime, Calendar toTime, int start,
        int maxResults); @Override long countEventsForEntity(DocumentReference entity); @Override long countEventsForEntity(DocumentReference entity, String type); @Override long countEventsForUser(User user); @Override long countEventsForUser(User user, String ip); @Override long countEventsForUser(User user, String ip, String type); @Override long countEvents(AuditEvent eventTemplate, Calendar fromTime, Calendar toTime);  }