конфигурация спящего режима - PullRequest
0 голосов
/ 27 ноября 2018

У меня проблема с моим сеансом гибернации.Я пытаюсь протестировать его, выбрасывая один запрос select, но я не понимаю, почему он не работает.Кажется, что сервер имеет бесконечность, когда я вызываю метод buildSessionFactory в коде в.

    package fr.utils;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;

public class HibernateConfig {

     public static SessionFactory getConfiguredSessionFactory() throws HibernateException {
        try {
            Configuration config = new Configuration();
            config.configure();
            StandardServiceRegistryBuilder serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties());
            SessionFactory sessionFactory = config.buildSessionFactory(serviceRegistry.build());
            return sessionFactory;
        }
        catch (HibernateException e) {
            e.printStackTrace();
            return null;
        }
     }
}

Мой файл конфигурации hibernate находится в папке src / main / ressources и имеет этот код внутри

    <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <!-- SQL Dialect -->
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

        <!-- Database Connection Settings -->
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:8888/yugioh_j2ee</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password"></property>
        <property name="hibernate.connection.pool_size">10</property>
        <property name="show_sql">true</property>
        <property name="hibernate.hbm2ddl.auto">update</property>
        <property name="spring.jpa.hibernate.ddl-auto">create</property>

        <property name="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
        <!-- Specifying Session Context -->
        <property name="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property>

        <!-- Mapping With Model Class Containing Annotations -->
        <mapping class="fr.metier.Player"/>
    </session-factory>
</hibernate-configuration>

Я действительно не понимаю, почему это не работает.

Спасибо за помощь.

...