-->
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: session.createCriteria ...list() return wrong result
PostPosted: Fri Apr 14, 2006 5:50 am 
Newbie

Joined: Fri Mar 03, 2006 6:16 am
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1

Mapping documents:
Code:
<hibernate-mapping package="com.ns.jphoenix.portal.component.forum.model">
    <class name="ForumCategory" lazy="true" table="JPHOENIX_FORUM_CATEGORYS">
        <id name="id" column="CATEGORY_ID" unsaved-value="null">
            <generator class="native"/>
        </id>
        <version name="version" type="calendar" column="TIME_OF_LAST_EDIT"/>
        <property name="timeOfCreation" type="calendar" column="TIME_OF_CREATION" not-null="true" />
        <property name="categoryTitle" type="string" column="CATEGORY_TITLE" />
        <set name="categoryForums" table="JPHOENIX_FORUMS" cascade="all" inverse="true" outer-join="true" lazy="true" order-by="TIME_OF_LAST_EDIT desc">
            <key column="CATEGORY_ID"/>
            <one-to-many class="Forum"/>
        </set>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
public List getCategorys() {
        Session session=hs.getSession();
        List lst=session.createCriteria(ForumCategory.class).addOrder(Property.forName("version").desc()).list();   
        return lst;
       
    }

Full stack trace of any exception that occurs: No exceptions

Name and version of the database you are using: MySql 5.0

The generated SQL (show_sql=true):
Code:
Hibernate: select this_.CATEGORY_ID as CATEGORY1_102_1_, this_.TIME_OF_LAST_EDIT as TIME2_102_1_, this_.TIME_OF_CREATION as TIME3_102_1_, this_.CATEGORY_TITLE as CATEGORY4_102_1_, categoryfo2_.CATEGORY_ID as CATEGORY11_3_, categoryfo2_.FORUM_ID as FORUM1_3_, categoryfo2_.FORUM_ID as FORUM1_103_0_, categoryfo2_.TIME_OF_LAST_EDIT as TIME2_103_0_, categoryfo2_.TIME_OF_CREATION as TIME3_103_0_, categoryfo2_.PARENT_ID as PARENT4_103_0_, categoryfo2_.THREAD_TITLE as THREAD5_103_0_, categoryfo2_.THREAD_CONTENT as THREAD6_103_0_, categoryfo2_.IP as IP103_0_, categoryfo2_.NR_OF_VISITS as NR8_103_0_, categoryfo2_.OPENED as OPENED103_0_, categoryfo2_.EDITABLE as EDITABLE103_0_, categoryfo2_.CATEGORY_ID as CATEGORY11_103_0_, categoryfo2_.USER_ID as USER12_103_0_ from JPHOENIX_FORUM_CATEGORYS this_ left outer join JPHOENIX_FORUMS categoryfo2_ on this_.CATEGORY_ID=categoryfo2_.CATEGORY_ID order by categoryfo2_.TIME_OF_LAST_EDIT desc, this_.TIME_OF_LAST_EDIT desc


Debug level Hibernate log excerpt:

The problem is that
Code:
List lst=session.createCriteria(ForumCategory.class).addOrder(Property.forName("version").desc()).list();

return some duplicated values, some values are duplicated, Eg. the result must return List with 6 objects but it returns List with 10 objects...
what I`m missing?

sorry for my english.


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.