我有这个豆子
public class Advertisement{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "pkid", nullable = false)
@Basic(fetch = FetchType.EAGER)
private long adPkId;
@Size(max = 50, message = "{long.value}")
@Column(name = "Name", unique = true, nullable = false, length = 50)
private String name;
@Size(max = 255, message = "{long.value}")
@Column(name = "Description", length = 255)
private String description;
}
我想按 id 返回所有数据顺序
getCurrentSession().createCriteria(Advertisement.class)
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.addOrder(Order.asc("adPkId")).list();
表中的数据采用从 1 到 7 的 ID 列表中返回的数据不是返回 ID 的顺序 (3 - 4 - 5 - 6 - 7 - 1 - 2)
如何解决