Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.dropwizard.hibernate;
 
 
 public class SessionFactoryHealthCheck extends HealthCheck {
     private final SessionFactory sessionFactory;
    private final String validationQuery;
    public SessionFactoryHealthCheck(SessionFactory sessionFactory,
                                     String validationQuery) {
        this. = sessionFactory;
        this. = validationQuery;
    }
    public SessionFactory getSessionFactory() {
        return ;
    }
    public String getValidationQuery() {
        return ;
    }
    @Override
    protected Result check() throws Exception {
        final Session session = .openSession();
        try {
            final Transaction txn = session.beginTransaction();
            try {
                session.createSQLQuery().list();
                txn.commit();
            } catch (Exception e) {
                if (txn.isActive()) {
                    txn.rollback();
                }
                throw e;
            }
        } finally {
            session.close();
        }
        return Result.healthy();
    }
New to GrepCode? Check out our FAQ X