@Bean
    @RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
    public EntityManagerFactory entityManagerFactory(
        @Qualifier("jpaVendorAdapter")
        final JpaVendorAdapter jpaVendorAdapter,
        @Qualifier("dataSource")
        final DataSource dataSource) {
        val ctx = JpaConfigurationContext.builder()
            .jpaVendorAdapter(jpaVendorAdapter)
            .persistenceUnitName("databaseAuthnContext")
            .dataSource(dataSource)
            .persistenceProvider(new CasHibernatePersistenceProvider(persistenceProviderContext))
            .packagesToScan(CollectionUtils.wrapSet("org.apereo.cas.adaptors.jdbc"))
            .build();
        val jpaProperties = ctx.getJpaProperties();
        jpaProperties.put("hibernate.dialect", databaseDialect);
        jpaProperties.put("hibernate.hbm2ddl.auto", this.hbm2ddl);
        jpaProperties.put("hibernate.jdbc.batch_size", 1);

        val factory = JpaBeans.newEntityManagerFactoryBean(ctx);
        factory.afterPropertiesSet();
        return factory.getObject();
    }
This is {@link DatabaseAuthenticationTestConfiguration}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-jdbc-authentication/src/test/java/org/apereo/cas/config/DatabaseAuthenticationTestConfiguration.java