I am using Java 1.7, and Hibernate 4.1.9. I'm relatively new to Hibernate, so if I left out any pivotal piece of information, just let me know. I have a javax.persistence.Entity
in my class called Meeting
that contains this:
@Column(name = "ballot_id")
private Long ballotId;
public Long getBallotId() {
return ballotId;
}
public void setBallotId(Long ballotId) {
this.ballotId = ballotId;
}
I am trying to construct a query like this:
Query query = session.createQuery("from Meeting m where m.ballotId=:ballotId");
query.setParameter("ballotId", someLongValue);
meeting = (Meeting) query.uniqueResult();
But I am getting a org.hibernate.exception.SQLGrammarException: Unknown column 'meeting0_.ballotId' in 'field list'
error. It seems as though when building the query like this, Hibernate does not check the annotations that indicate that the database column name is different from the object's property name. Is there another way of doing this, or is there something I need to add for this? Maybe I missed something, or got the HQL wrong?
Thanks!