-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: weird HQL problem:select query doesn't retrieve the Id field
PostPosted: Thu Nov 18, 2010 5:52 am 
Newbie

Joined: Thu Nov 18, 2010 5:37 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.