<commit_before>package hello.web;

import hello.domain.World;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateUtil {

    private static final SessionFactory SESSION_FACTORY = createSessionFactory();
    private static final ThreadLocal<Session> SESSIONS = new ThreadLocal<>();
    
    public static Session getSession() {
        Session session = SESSIONS.get();
        if (session == null) {
            session = SESSION_FACTORY.openSession();
            SESSIONS.set(session);
        }
        return session;
    }
    
    public static void closeSession() {
        Session session = SESSIONS.get();
        if (session != null) {
            session.close();
            SESSIONS.remove();
        }
    }
    
    private static SessionFactory createSessionFactory() {
        Configuration configuration = configuration();
        configuration.setProperty("hibernate.dialect ", MySQLDialect.class.getName());
        configuration.setProperty("hibernate.cache.use_query_cache", "false");
        configuration.setProperty("show_sql", "false");
        configuration.addAnnotatedClass(World.class);
        ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder().applySettings(configuration.getProperties());
        return configuration.buildSessionFactory(serviceRegistryBuilder.buildServiceRegistry());
    }
    
    private static Configuration configuration() {
        boolean jndi = Boolean.parseBoolean(System.getProperty("jndi", "true"));
        Configuration configuration = new Configuration();
        if (jndi) {
            configuration.configure("/hibernate-jndi.cfg.xml");
        } else {
            configuration.configure("/hibernate-local.cfg.xml");
        }
        return configuration;
    }
    
}<commit_msg>use non-jndi configuration for spark<commit_after>package hello.web;

import hello.domain.World;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateUtil {

    private static final SessionFactory SESSION_FACTORY = createSessionFactory();
    private static final ThreadLocal<Session> SESSIONS = new ThreadLocal<>();
    
    public static Session getSession() {
        Session session = SESSIONS.get();
        if (session == null) {
            session = SESSION_FACTORY.openSession();
            SESSIONS.set(session);
        }
        return session;
    }
    
    public static void closeSession() {
        Session session = SESSIONS.get();
        if (session != null) {
            session.close();
            SESSIONS.remove();
        }
    }
    
    private static SessionFactory createSessionFactory() {
        Configuration configuration = configuration();
        configuration.setProperty("hibernate.dialect ", MySQLDialect.class.getName());
        configuration.setProperty("hibernate.cache.use_query_cache", "false");
        configuration.setProperty("show_sql", "false");
        configuration.addAnnotatedClass(World.class);
        ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder().applySettings(configuration.getProperties());
        return configuration.buildSessionFactory(serviceRegistryBuilder.buildServiceRegistry());
    }
    
    private static Configuration configuration() {
        boolean jndi = Boolean.parseBoolean(System.getProperty("jndi", "true"));
        Configuration configuration = new Configuration();
        // We're always going to use the -local config now since there were previous 
        // problems with the jndi config.
        /*
        if (jndi) {
            configuration.configure("/hibernate-jndi.cfg.xml");
        } else {
            configuration.configure("/hibernate-local.cfg.xml");
        }
        */
        configuration.configure("/hibernate-local.cfg.xml");
        return configuration;
    }
    
}
{'fraction_non_alphanumeric': 0.10096618357487923, 'fraction_numerical': 0.0, 'mean_word_length': 3.0164888457807955, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4146005', 'n_tokens_mistral': 1050, 'n_tokens_neox': 996, 'n_words': 215}