Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.dropwizard.hibernate;
 
public abstract class HibernateBundle<T extends Configurationimplements ConfiguredBundle<T>, DatabaseConfiguration<T> {
    private static final String DEFAULT_NAME = "hibernate";
    private SessionFactory sessionFactory;
    private final ImmutableList<Class<?>> entities;
    protected HibernateBundle(Class<?> entityClass<?>... entities) {
        this(ImmutableList.<Class<?>>builder().add(entity).add(entities).build(),
             new SessionFactoryFactory());
    }
    protected HibernateBundle(ImmutableList<Class<?>> entities,
                              SessionFactoryFactory sessionFactoryFactory) {
        this. = entities;
        this. = sessionFactoryFactory;
    }
    @Override
    public final void initialize(Bootstrap<?> bootstrap) {
    }

    
        return new Hibernate4Module();
    }

    
Override to configure the name of the bundle (It's used for the bundle health check and database pool metrics)
    protected String name() {
        return ;
    }
    @Override
    public final void run(T configurationEnvironment environmentthrows Exception {
        final DataSourceFactory dbConfig = getDataSourceFactory(configuration);
        this. = .build(thisenvironmentdbConfigname());
        environment.jersey().register(new UnitOfWorkApplicationListener());
        environment.healthChecks().register(name(),
                                            new SessionFactoryHealthCheck(,
                                                                          dbConfig.getValidationQuery()));
    }
    public SessionFactory getSessionFactory() {
        return ;
    }
    protected void configure(org.hibernate.cfg.Configuration configuration) {
    }
New to GrepCode? Check out our FAQ X