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