使用简单示例hibernate Java的奇怪错误

时间:2016-02-13 23:25:35

标签: java hibernate netbeans

我在hibernate Java中尝试了简单的例子,我使用netbeans设置来创建所有文件。但是当我尝试运行一个简单的例子时,我不能

 package javaapplication19;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

public class JavaApplication19 {
    SessionFactory factory;
    private static final Logger LOGGER = Logger.getLogger("Hibernate-Tutorial");
    public static void main(String[] args) {
        JavaApplication19 main = new JavaApplication19();
        main.run();
    }
    public void run() {
        SessionFactory sessionFactory = null;
        Session session = null;
        try {
            Configuration configuration = new Configuration().configure();
            ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
            sessionFactory = configuration.buildSessionFactory(serviceRegistry);
            sessionFactory = configuration.buildSessionFactory(serviceRegistry);
            session = sessionFactory.openSession();
        } catch (Exception e) {
            // LOGGER.log(Level.SEVERE, e.getMessage(), e);
        } finally {
            if (session != null) {
                session.close();
            }
            if (sessionFactory != null) {
                sessionFactory.close();
            }
        }
    }
}

输出错误日志。无法修复,而且很奇怪,因为是netbeans的自动代码添加

run:
feb 14, 2016 12:22:23 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
feb 14, 2016 12:22:23 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.7.Final}
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
feb 14, 2016 12:22:23 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Correoelectronico.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Modulo.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Direccion.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Profesormodulo.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Tiposbasicos.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Municipios.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Usuario.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Cicloformativo.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: pojo/Profesor.hbm.xml
feb 14, 2016 12:22:23 AM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
feb 14, 2016 12:22:23 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
feb 14, 2016 12:22:23 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/hibernate1?zeroDateTimeBehavior=convertToNull]
feb 14, 2016 12:22:23 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=hibernate1, password=****}
feb 14, 2016 12:22:23 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
feb 14, 2016 12:22:23 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
feb 14, 2016 12:22:24 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
feb 14, 2016 12:22:24 AM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
feb 14, 2016 12:22:24 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
feb 14, 2016 12:22:24 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
feb 14, 2016 12:22:24 AM org.hibernate.type.TypeFactory$TypeScopeImpl injectSessionFactory
WARN: HHH000233: Scoping types to session factory org.hibernate.internal.SessionFactoryImpl@28dcca0c after already scoped org.hibernate.internal.SessionFactoryImpl@45d84a20

0 个答案:

没有答案