-->
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: Order association collection before passing it.
PostPosted: Sat Nov 07, 2009 7:14 am 
Newbie

Joined: Sat Nov 07, 2009 7:00 am
Posts: 2
Hi,

I am having association in pFieldSet.hbm.xml:

<set inverse="true"
lazy="false"
name="pFields"
cascade="all">
<key column="FIELD_SET_ID"/>
<one-to-many class="PFieldVO"/>
</set>

I am fetching the records using criteria:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Criteria crit = session.createCriteria(PFieldSetVO.class);
crit.add(Restrictions.eq("EntityId", requestVO.getEntityId()));
crit.add(Restrictions.eq("context", requestVO.getContext()));
crit.createAlias("pFields", "pField",CriteriaSpecification.LEFT_JOIN);
crit.add(Restrictions.eq("pField.isRemoved", false));
crit.addOrder( Order.asc("pField.dataType") );
crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);

List<PFieldSetVO> results = crit.list();

Here all working fine except crit.addOrder( Order.asc("pField.dataType") );. I want to order the collection records of pFields based on dataType column that is of PFieldVO class.
Noted that crit.add(Restrictions.eq("pField.isRemoved", false));is working fine.

whereas EntityId and context belong to PFieldSetVO class.

Any idea why ordering is not taking place in collection/set here.

Thanks


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.