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<?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>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/hibernate1</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">123456</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="connection.pool_size">1</property>
<property name="show_sql">true</property>
<!--property name="hbm2ddl.auto">create-drop</property-->
<mapping resource="samples/Event.hbm.xml"/>
<mapping class="samples.Event"/>
</session-factory>
</hibernate-configuration>
HibernateUtil
Código Java:
Ver originalpackage samples;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
public class HibernateUtil
{
// private static final SessionFactory sessionFactory;
private static final SessionFactory factory;
static
{
try
{
Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().
applySettings(configuration.getProperties());
factory = configuration.buildSessionFactory(builder.build());
// sessionFactory = new Configuration().configure("./hibernate.cfg.xml").buildSessionFactory();
} catch (HibernateException he)
{
System.
err.
println("Ocurrió un error en la inicialización de la SessionFactory: " + he
); }
}
public static SessionFactory getSessionFactory()
{
return factory;
}
}
Error que me esta arrojando
Código Java:
Ver originalmar 16, 2015 2:51:20 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
mar 16, 2015 2:51:20 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.8.Final}
mar
16,
2015 2:51:20 PM org.
hibernate.
cfg.
Environment <clinit
>INFO: HHH000206: hibernate.properties not found
mar
16,
2015 2:51:20 PM org.
hibernate.
cfg.
Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
mar 16, 2015 2:51:20 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
mar 16, 2015 2:51:20 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
mar 16, 2015 2:51:20 PM org.hibernate.cfg.Configuration addResource
INFO
: HHH000221
: Reading mappings from resource
: samples
/Event.
hbm.
xmlmar 16, 2015 2:51:20 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO
: HHH000401
: using driver
[org.
postgresql.
Driver] at
URL [jdbc
:postgresql
://localhost:5432/hibernate1]mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO
: HHH000046
: Connection properties
: {user
=postgres, password
=****}mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
mar 16, 2015 2:51:21 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
mar 16, 2015 2:51:21 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO
: HHH000424
: Disabling contextual LOB creation as createClob
() method threw error
: java.
lang.
reflect.
InvocationTargetExceptionmar 16, 2015 2:51:21 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
mar 16, 2015 2:51:21 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select nextval ('hibernate_sequence')
Hibernate
: insert into
Event (nombre, email, telefono, id
) values
(?,
?,
?,
?)