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.