-->
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: @OrderBy takes precedence over org.hibernate.criterion.Order
PostPosted: Tue Aug 14, 2012 4:25 am 
Newbie

Joined: Sun Oct 30, 2011 5:43 am
Posts: 13
i have an entity Advertisement as follows:

Code:
    @Entity
    @Table(name = "advertisement", catalog = "advertisedb")
    public class Advertisement implements java.io.Serializable {
   
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "pkid", nullable = false)
        @Basic(fetch = FetchType.EAGER)
        private Long pkid;
   
        @OneToMany(fetch = FetchType.EAGER, mappedBy = "advertisement")
        @OrderBy("name")
        private Set<Page> pages = new HashSet<Page>(0);


i am using @OrderBy to order the pages collection when it's retrieved.
and i have a DAO method to retrieve all ads as follows:

Code:
     public List listData(Advertisement ad) {
            Criteria criteria = getCurrentSession().createCriteria(Advertisement.class).addOrder(
                    Order.asc("name"));
            return criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
                    .list();
        }


problem is that when i am trying to get all Advertisements, they are ordered by pages name not by advertisement name as in the DAO method.

please advise how to fix that,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.