Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/05/2013, 11:52
Avatar de fpalomar
fpalomar
 
Fecha de Ingreso: noviembre-2003
Mensajes: 123
Antigüedad: 20 años, 5 meses
Puntos: 3
Hibernate no pasa los datos

Hola,

Soy nuevo en hibernate, pero creo que he seguido correctamente el manual de configuración.

Este es el archivo hibernate.cfg.xml:
Código:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>

		<!-- Database connection settings -->
		<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/bbw</property>
		<property name="hibernate.connection.username">root</property>
		<property name="hibernate.connection.password">root</property>

		<!-- JDBC connection pool (use the built-in) 
		<property name="connection.pool_size">1</property> -->

		<!-- SQL dialect 
		<property name="dialect">org.hibernate.dialect.HSQLDialect</property> -->
		<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

		<!-- Enable Hibernate's automatic session context management -->
		<property name="hibernate.current_session_context_class">thread</property>
		
		<!-- Transaction properties -->
		<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

		<!-- Echo all executed SQL to stdout -->
		<property name="show_sql">true</property>
		
		<mapping resource="Usuario.hbm.xml"/>
	</session-factory>
</hibernate-configuration>
El arcvhivo que representa la clase de java a mapear es:

Código:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated Nov 28, 2012 4:05:29 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
	<class name="registrar.model.Usuario" table="usuario" catalog="bbw">
		
		<id name="usuario" type="string">
			<column name="usuario" />
			<generator class="assigned" />
		</id>
		
		<property name="nombre" type="string">
			<column name="nombre" length="15" />
		</property>
		
		<property name="apellido" type="string">
			<column name="apellido" length="10" />
		</property>
		
		<property name="NIFCIF" type="string">
			<column name="NIFCIF" length="9" />
		</property>
		
		<property name="email" type="string">
			<column name="email" length="30" />
		</property>
		
		<property name="telefono" type="string">
			<column name="telefono" length="9" />
		</property>
		
		<property name="empresa" type="string">
			<column name="empresa" length="15" />
		</property>
		
		<property name="departamento" type="string">
			<column name="departamento" length="10" />
		</property>
		
		<property name="contrasena" type="string">
			<column name="contrasena" length="15" />
		</property>

	</class>
</hibernate-mapping>
El problema es que en la base de datos no inserta ninguno, lo puedo ver en la consola por que pone:

Código:
Hibernate: insert into bbw.usuario (nombre, apellido, NIFCIF, email, telefono, empresa, departamento, contrasena, usuario) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
¿Me he olvidado de algo?

Saludos