org.hibernate.exception.SQLGrammarException: could not extract ResultSet

In the stacktrace, there is a line that points towards the problem:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'product0_.product' in 'field list'

If you see unknown column, the first thing that comes to my mind is that there is some error in the mapping of the fields in the class.

@Id
@Column(name="product-id")
private int id;
@Column(name="product-name")
private String name;
@Column(name="product-description")
private String description;
@Column(name="product-price")
private float price;

And when you see this together with the output in the stacktrace i mentioned above, you think, well, there is not a product0_.product column name, the closest thing is just product, followed by a hyphen, maybe its the hyphen what it gives some troubles.

After googling a bit, i found this answer from another question, that points that using hyphens is possible, but it has a special requirement, perhaps hibernate is not dealing with this correctly.

So to summarize, try without hyphens in the schema, in both places, the database, and the @Entity.

Leave a Comment