MySQL 中具有休眠条件 API 的 Orderby Timestamp 列抛出错误
Orderby Timestamp column in MySQL with hibernate Criteria API throws error
我正在使用休眠从 MySQL 数据库中检索数据。
@Transactional
public List<PendingDomainEntity> listPendingDomain(int count, int offset)
throws DaoException {
try {
Criteria listCriteria = sessionFactory.getCurrentSession().createCriteria(PendingDomainEntity.class);
listCriteria.addOrder(Order.asc("domaincreateddt"));
listCriteria.setMaxResults(count);
listCriteria.setFirstResult(offset);
Criterion domainstatus = Restrictions.eq("domainstatus", "Pending").ignoreCase();
listCriteria.add(domainstatus);
@SuppressWarnings("unchecked")
List<PendingDomainEntity> pendingDomainList = (List<PendingDomainEntity>) listCriteria.list();
LOGGER.debug("Regg-Service: The pending domain list is:={}", pendingDomainList);
return pendingDomainList;
} catch (Exception ex) {
LOGGER.error("Exception: Service: Error while retrieving the pending domains list");
throw new DaoException(ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
}
}
这是在 PendingDomainEntity 类中声明 domainCreatedDt 的方式
@Column(name = "DOMAINCREATEDDT")
private Timestamp domainCreatedDt;
我收到以下异常消息
could not resolve property: domaincreateddt of: mypackage.DTO.PendingDomainEntity
但是当我为订单使用不同的列名时,它工作正常。时间戳列的排序依据是否有任何限制?
查看有关 HQL 的文档章节 (同样适用于 Criteria API):
16.1. Case Sensitivity
With the exception of names of Java classes and properties, queries are case-insensitive. So SeLeCT is the same as sELEct is the same as SELECT, but org.hibernate.eg.FOO is not org.hibernate.eg.Foo, and foo.barSet is not foo.BARSET....
这是 JAVA 姓名:
private Timestamp domainCreatedDt;
这意味着,这 与 不同:
listCriteria.addOrder(Order.asc("domaincreateddt"));
简单来说就是domainCreatedDt
我正在使用休眠从 MySQL 数据库中检索数据。
@Transactional
public List<PendingDomainEntity> listPendingDomain(int count, int offset)
throws DaoException {
try {
Criteria listCriteria = sessionFactory.getCurrentSession().createCriteria(PendingDomainEntity.class);
listCriteria.addOrder(Order.asc("domaincreateddt"));
listCriteria.setMaxResults(count);
listCriteria.setFirstResult(offset);
Criterion domainstatus = Restrictions.eq("domainstatus", "Pending").ignoreCase();
listCriteria.add(domainstatus);
@SuppressWarnings("unchecked")
List<PendingDomainEntity> pendingDomainList = (List<PendingDomainEntity>) listCriteria.list();
LOGGER.debug("Regg-Service: The pending domain list is:={}", pendingDomainList);
return pendingDomainList;
} catch (Exception ex) {
LOGGER.error("Exception: Service: Error while retrieving the pending domains list");
throw new DaoException(ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
}
}
这是在 PendingDomainEntity 类中声明 domainCreatedDt 的方式
@Column(name = "DOMAINCREATEDDT")
private Timestamp domainCreatedDt;
我收到以下异常消息
could not resolve property: domaincreateddt of: mypackage.DTO.PendingDomainEntity
但是当我为订单使用不同的列名时,它工作正常。时间戳列的排序依据是否有任何限制?
查看有关 HQL 的文档章节 (同样适用于 Criteria API):
16.1. Case Sensitivity
With the exception of names of Java classes and properties, queries are case-insensitive. So SeLeCT is the same as sELEct is the same as SELECT, but org.hibernate.eg.FOO is not org.hibernate.eg.Foo, and foo.barSet is not foo.BARSET....
这是 JAVA 姓名:
private Timestamp domainCreatedDt;
这意味着,这 与 不同:
listCriteria.addOrder(Order.asc("domaincreateddt"));
简单来说就是domainCreatedDt