I have an entity with two Date fields. One of them is named "end"
Code:
public class OrganizationMembership {
....
@Temporal (value = TemporalType.TIMESTAMP)
@Column(nullable = false, updatable = true)
private Date startDate;
@Temporal (value = TemporalType.TIMESTAMP)
@Column(nullable = false, updatable = true)
private Date end;
....
}
If I execute JP-QL request like below
Code:
entityManager.createQuery("select om from OrganizationMembership as om "
+ "WHERE om.startDate <= :date AND :date <= om.end ")
.setParameter("date", date).getResultList();
I see the following in the log
Code:
select organizati0_.ID as ID9_, end as end9_, organizati0_.startDate as startDate9_
from OrganizationMembership organizati0_
where organizati0_.startDate<=? and ?<=end
please take a notice that in the last condition "? <= end" is used instead of fully qualified name "tableName.fieldName"
in the selected columns list it is defined as
"end as end9_"Is it a problem of SQL logging or "end" is some reserved field for the hibernate ?
I also use Hibernate-Filters on that Entity with same condition, it works the same way here
"select organizati1_.user from OrganizationMembership organizati1_ where organizati1_.startDate <= ? AND ? <= end"
After renaming the "end" to the "endDate" I see the fully-qualified field-name ${table.field} in the log.
Environment: Hibernate 3.5.3-Final but on previous versions I experienced the same issue. DB - MySQL 5.1
JBoss-Seam 2.2.1-CR1, Tomcat-6