7

I am getting the following error from my Hibernate code:

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'bulletin0_.bulletin_date' in 'field list'

There is no such bulletin_date column in my table, nor is there such a name in my model class. It's just called date. Here is the line where I'm getting the error.

Query query = session.createQuery("from Bulletin where approved = true");

Here is my model class (I'm leaving out the getters and setters):

public class Bulletin {
    @Id
    @Column(name="id")
    @GeneratedValue
    private int id;

    @Column(name="date")
    private String date;

    @Column(name="name")
    private String name;

    @Column(name="subject")
    private String subject;

    @Column(name="note")
    private String note;

    @Column(name="approved")
    private boolean approved;
}

Here is my table definition.

+----------+---------------+------+-----+---------+----------------+
| Field    | Type          | Null | Key | Default | Extra          |
+----------+---------------+------+-----+---------+----------------+
| id       | int(11)       | NO   | PRI | NULL    | auto_increment |
| date     | varchar(10)   | YES  |     | NULL    |                |
| name     | varchar(30)   | YES  |     | NULL    |                |
| subject  | varchar(50)   | YES  |     | NULL    |                |
| note     | varchar(2500) | YES  |     | NULL    |                |
| approved | tinyint(1)    | YES  |     | NULL    |                |
+----------+---------------+------+-----+---------+----------------+
1
  • Date could be a reserve keyword. Try to change the name 'date' to a different name in your entity & DB. Commented Apr 10, 2014 at 14:27

1 Answer 1

4

I had the wrong column names in my Bulletin.hbm.xml file. When I corrected it, the problem was solved.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.