Hi all.
I'm having troubles with hibernate. From a simple query like (hbtpl is a HibernateTemplate class)
String parametros[] = {usuario.getLogin(), usuario.getPassword()};
the mysql Log shows:Code:List resultado = hbtpl.find("from Estudiante estudiante where estudiante.login = ? and estudiante.password = ?",parametros);
Part of my application-context is:Code:select estudiante0_.id as id0_, estudiante0_.login as login0_, estudiante0_.password as password0_, estudiante0_.nombre as nombre0_, estudiante0_.telefono as telefono0_, estudiante0_.mail as mail0_, estudiante0_.direccion as direccion0_, estudiante0_.universidad as universi8_0_ from estudiante estudiante0_ where estudiante0_.login='the-login' and estudiante0_.password='the-password'
And seminario.hbm.xml:Code:<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"><ref bean="dataSource"/></property> <property name="mappingResources"> <value>seminario.hbm.xml</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop> </props> </property> </bean>
Still don't know why hibernate appends a "0_" in the queryCode:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping auto-import="true" default-lazy="false"> <class name="seminario.Estudiante" table="estudiante"> <id name="id" column="id"> <generator class="identity"/> </id> <property name="login" column="login"/> <property name="password" column="password"/> <property name="nombre" column="nombre"/> <property name="telefono" column="telefono"/> <property name="mail" column="mail"/> <property name="direccion" column="direccion"/> <property name="universidad" column="universidad"/> </class> </hibernate-mapping>
Thanks in advance and sorry for my poor English!



Reply With Quote
. As the login failed, I thought it was the SQL query. Now I inserted a field and the query works fine.