-->
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: filtered collections and @OrderBy
PostPosted: Fri May 24, 2013 5:49 am 
Beginner
Beginner

Joined: Wed Sep 06, 2006 12:08 pm
Posts: 48
Location: Warsaw - Poland - Europe - Milky Way
Hi

My config:
* hibernate-3.3.1.GA
* hibernate-annotations-3.3.1.GA
* hibernate-entitymanager-3.4.0.GA

Whether @OrderBy should be taken into account when using filtered collections?

I can see that ordering defined by @OrderBy is not used in SELECT generated by filtered collections mechanism.

My mapping looks like this:

Code:
@Entity
@Table(name="MOTHER")
public class Mother
{
   private List<Child>        child;

   @OneToMany(fetch=FetchType.LAZY, mappedBy="mother")
   @org.hibernate.annotations.OrderBy(clause="seqno desc")
   public List<Child> getChild()
   {
      return child;
   }


Code:
@Entity
@Table(name="CHILD")
public class Child
{
   Mother mother;

   @ManyToOne(fetch=FetchType.LAZY)
   public Mother  getMother ()
   {
      return mother;
   }



And an example of piece of code using createFilter mechanism:

Code:
      final List<Child> list =
         session
         .createFilter(mother.getChild(), "where status is not null")
         .setMaxResults(1)
         .list();


And there is no ORDER BY is SQL generated by Hibernate.
Is it OK?

Regards,
Adam


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.