Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0
Mapping documents:
<class
name="it.sella.cms.hbm.CmsMaCategory"
table="cms_ma_category"
>
<id
name="cgId"
type="java.lang.Long"
column="cg_id"
>
<generator class="identity"/>
</id>
Code between sessionFactory.openSession() and session.close():
List l = s.createQuery("from it.sella.cms.hbm.CmsMaCategory as st").list();
int size = l.size();
for(Iterator itr=l.iterator();size>0;size--){
CmsMaCategory st = (CmsMaCategory)itr.next();
s.evict(st);
LOG.info("st id/nme: "+st.getCgId()+"/"+st.getCgNme()+"/"+st.getCgDescr());
}
Full stack trace of any exception that occurs:
None.
Name and version of the database you are using:
MySQL 4.1
The generated SQL (show_sql=true):
select cmsmacateg0_.cg_id as cg1_, cmsmacateg0_.cg_nme as cg2_8_, cmsmacateg0_.cg_descr as cg3_8_ from cms_ma_category cmsmacateg0_
Debug level Hibernate log excerpt:
The DB query (hibernate generated sql) produces:
Code:
mysql> select cmsmacateg0_.cg_id as cg1_, cmsmacateg0_.cg_nme as cg2_8_, cmsmacateg0_.cg_descr as cg3_8_ from cms_ma_category cmsmacateg0_
-> ;
+------+--------+-----------------+
| cg1_ | cg2_8_ | cg3_8_ |
+------+--------+-----------------+
| 1 | Java | Java Category |
| 2 | Oracle | Oracle Category |
+------+--------+-----------------+
2 rows in set (0.00 sec)
But when I run the program, I get the output:
Code:
Hibernate: select cmsmacateg0_.cg_id as cg1_, cmsmacateg0_.cg_nme as cg2_8_, cmsmacateg0_.cg_descr as cg3_8_ from cms_ma_category cmsmacateg0_
2005-09-27 20:09:26,157 [main] INFO Test - st id/nme: 4294967297/Java/Java Category
2005-09-27 20:09:26,158 [main] INFO Test - st id/nme: 4294967298/Oracle/Oracle Category
Why is Hibernate not displaying the correct id corresponding to Java (1) and Oracle (2)? This is an application which was previously working in Hibernate2. After migration to 3.0, we are facing this.
Thanks in Advance.