hi all,
I'm using Hibernate 3.2 along with Spring 2.5 and MySql 5.In my DAOs I use Spring's HibernateTemplate.find() method with query string "from Messages where lang="+"'"+lang+"'" and I've noticed that in all Messages POJOs returned from the query the id field is set with its default value (zero,that is).But when I use the query "select id from Messages" the ids in the list returned are correct.Is there a solution to that problem?
here is the Messages.hbm.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="gr.nikoslianeris.model.Messages" table="messages">
<id column="id" type="long" access="field">
<generator class="native"/>
</id>
<property column="mesname" name="mesname" type="string"/>
<property column="message" name="message" type="string"/>
<property column="lang" name="lang" type="string"/>
</class>
</hibernate-mapping>
the hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/lianeris</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<mapping resource="gr/nikoslianeris/model/Messages.hbm.xml"/>
<mapping resource="gr/nikoslianeris/model/News.hbm.xml"/>
<mapping resource="gr/nikoslianeris/model/Portfolio.hbm.xml"/>
<mapping resource="gr/nikoslianeris/model/Articles.hbm.xml"/>
</session-factory>
</hibernate-configuration>
thank in advance for your time