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.