-->
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: Ordering none associated collections - via database query
PostPosted: Tue Jun 21, 2011 10:12 am 
Newbie

Joined: Thu Apr 02, 2009 9:02 am
Posts: 2
Hello,

In my @Entity I want to specify the column by which the data brought back from the database is to be ordered. Also I want the ordering to take place in the database i.e. via the order by clause of the query. Can you please tell me which annotation to specify in order to achieve this.

Please note, there is no entity association or relationship involved i.e. the autogenerated query brings back one collection of data that is not associated with any other entity.

part of my entity is as follows:
=======================
Code:
@Entity
@Table(name="status")
public class StatusBean {
    DAOFactory daoFactory = DAOFactory.instance(DAOFactory.HIBERNATE);
    private static final Logger LOGGER = Logger.getLogger(Status.class.getName(), Constants.messages);
   //default serial version id, required for serializable classes.
   private static final long serialVersionUID = 1L;

   @Column(updatable = false, insertable = true, name="created_by", nullable = false, length=20)
   public String getCreatedBy() {
      return createdBy;
...




part of the method that brings back the collection that I want to sort/order by a specified column:
=========================================================================
Code:
    //@org.hibernate.annotations.OrderBy(clause = "status_desc")
    //@OrderBy("statusDesc")
    public List<StatusBean> getStatus(StatusBean statusBean) throws NoCriterionException, Exception {
        // Prepare the DAOs
        StatusDAO statusDAO = daoFactory.getStatusDAO();
...


Thank you


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.