hibernate3.HibernateQueryException: Books is not mapped [SELECT COUNT(*) FROM Books];
Hibernate is trying to say that it does not know an entity named "Books". Let's look at your entity:
@javax.persistence.Entity
@javax.persistence.Table(name = "Books")
public class Book {
Right. The table name for Book
has been renamed to "Books" but the entity name is still "Book" from the class name. If you want to set the entity name, you should use the name on the @Entity
annotation:
// this allows you to use the entity Books in HQL queries
@javax.persistence.Entity(name = "Books")
public class Book {
That sets both the entity name and the table name.