When a type maps to multiple columns and that type is used in HQL the generated SQL will order the values in different manner in the Order By clause then it does in the Where clause. The Order By clause assumes the fields are mapped in order of importance, while the where clause assumes not field is more important then any other.
For example assume a database stores a timestamp you using multiple fields (T2SCEN T2SYER T2SMTH T2SDAY T2STIM : century year month day time) and that there is a type that turns those fields into a Calendar. Now that type is used in an entity class named WorkOrder with a field named scheduled. The following HQL query:
Select wo From WorkOrder wo WHERE wo.scheduled > :scheduled Order By wo.scheduled
Will generate the following SQL
The Order By clause will order the values as one would expect for date, that is 2012-05-03T12:12:12 comes after 0001-12-01T00:00:00.
The Where clause on the other hand implies that 2012-05-03T12:12:12 does not come after 0001-12-01T00:00:00, since the month 5>12 will be false.
Java 1.7.0 Eclipse 3.7.2