Ver Mensaje Individual
  #8 (permalink)  
Antiguo 16/03/2015, 13:19
susi141
 
Fecha de Ingreso: agosto-2011
Mensajes: 73
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: Aprendiendo Hibernate con Eclipse y postgres

Bueno he logrado conectarme a la base de datos pero aun tengo algunos problemas, por lo que he podido ver es un problema con al versión de hibernate que estoy usando. Hibernate 4.3.8

Aqui voy a dejar el error, el hibernate.cfg.xml y el HibernateUtil a ver si me puedes ayudar a dar con el error.

hibernate.cfg.xml

Código Java:
Ver original
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-configuration PUBLIC
  3.         "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  4.         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  5. <hibernate-configuration>
  6.     <session-factory>
  7.         <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
  8.         <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/hibernate1</property>
  9.         <property name="hibernate.connection.username">postgres</property>
  10.         <property name="hibernate.connection.password">123456</property>
  11.         <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
  12.        
  13.         <property name="connection.pool_size">1</property>
  14.         <property name="show_sql">true</property>
  15.         <!--property name="hbm2ddl.auto">create-drop</property-->
  16.        
  17.         <mapping resource="samples/Event.hbm.xml"/>
  18.         <mapping class="samples.Event"/>
  19.     </session-factory>
  20. </hibernate-configuration>

HibernateUtil

Código Java:
Ver original
  1. package samples;
  2.  
  3. import org.hibernate.HibernateException;
  4. import org.hibernate.SessionFactory;
  5. import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
  6. import org.hibernate.cfg.Configuration;
  7.  
  8. public class HibernateUtil
  9. {  
  10.    // private static final SessionFactory sessionFactory;
  11.     private static final SessionFactory factory;
  12.  
  13.     static
  14.     {
  15.         try
  16.         {
  17.             Configuration configuration = new Configuration().configure();
  18.             StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().
  19.             applySettings(configuration.getProperties());
  20.             factory = configuration.buildSessionFactory(builder.build());
  21.  
  22.            // sessionFactory = new Configuration().configure("./hibernate.cfg.xml").buildSessionFactory();
  23.         } catch (HibernateException he)
  24.         {
  25.            System.err.println("Ocurrió un error en la inicialización de la SessionFactory: " + he);
  26.            throw new ExceptionInInitializerError(he);
  27.         }
  28.     }  
  29.  
  30.     public static SessionFactory getSessionFactory()
  31.     {
  32.         return factory;
  33.     }
  34. }

Error que me esta arrojando

Código Java:
Ver original
  1. mar 16, 2015 2:51:20 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
  2. INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
  3. mar 16, 2015 2:51:20 PM org.hibernate.Version logVersion
  4. INFO: HHH000412: Hibernate Core {4.3.8.Final}
  5. mar 16, 2015 2:51:20 PM org.hibernate.cfg.Environment <clinit>
  6. INFO: HHH000206: hibernate.properties not found
  7. mar 16, 2015 2:51:20 PM org.hibernate.cfg.Environment buildBytecodeProvider
  8. INFO: HHH000021: Bytecode provider name : javassist
  9. mar 16, 2015 2:51:20 PM org.hibernate.cfg.Configuration configure
  10. INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
  11. mar 16, 2015 2:51:20 PM org.hibernate.cfg.Configuration getConfigurationInputStream
  12. INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
  13. mar 16, 2015 2:51:20 PM org.hibernate.cfg.Configuration addResource
  14. INFO: HHH000221: Reading mappings from resource: samples/Event.hbm.xml
  15. mar 16, 2015 2:51:20 PM org.hibernate.cfg.Configuration doConfigure
  16. INFO: HHH000041: Configured SessionFactory: null
  17. mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  18. WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
  19. mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  20. INFO: HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/hibernate1]
  21. mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  22. INFO: HHH000046: Connection properties: {user=postgres, password=****}
  23. mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  24. INFO: HHH000006: Autocommit mode: false
  25. mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  26. INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
  27. mar 16, 2015 2:51:21 PM org.hibernate.dialect.Dialect <init>
  28. INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
  29. mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
  30. INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
  31. mar 16, 2015 2:51:21 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
  32. INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
  33. mar 16, 2015 2:51:21 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
  34. INFO: HHH000397: Using ASTQueryTranslatorFactory
  35. Hibernate: select nextval ('hibernate_sequence')
  36. Hibernate: insert into Event (nombre, email, telefono, id) values (?, ?, ?, ?)