Hi,
I have come what seems like a bug...
I have a class User which contains the column:
Code:
@Column(name = "some_date", nullable = true)
public Date getSomeDate( ) {
return someDate;
}
Order the results like so:
Code:
Criteria criteria = sessionFactory.getCurrentSession( ).createCriteria( User.class );
criteria.addOrder( Order.asc( "some_date" ) );
Hibernate throws the exception:
Code:
org.hibernate.QueryException: could not resolve property: some_date of: com.test.User
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1468)
at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:62)
at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1443)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:483)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:443)
at org.hibernate.criterion.Order.toSqlString(Order.java:68)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getOrderBy(CriteriaQueryTranslator.java:394)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:114)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:83)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1687)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
...
When removing the underscores from the column name and order query, everything works fine. So, it appears hibernate does not like underscores when ordering, has anyone come across this issue?
I'm using hibernate version 3.5.6-Final.