While the online tutorial which ADDS a record to a database works without a hitch, any attempt to QUERY the db with Hibernate fails with the same error message: “net.sf.hibernate.exceptionSQLGrammarException: Could not execute query”.
If I’ve successfully connected to the Pubs db in MS SQLServer using the Database explorer, and if I can ADD rows to the Authors table using the online tutorial, what is there about the following attempt to SEARCH the authors table that is wrong?
public static void main(String[] args)
{
try
{
Authors authors = new Authors();
Session session = SessionManager.currentSession();
Query q = session.createQuery(“from Authors a”);
List authorsList = q.list();
//I tried this syntax too, with the same faulty result
// List authorsList = session.find(“from Authors a”);
System.out.println(“Number of Objects: ” + authorsList.size());
}
catch(HibernateException e)
{
System.out.println(e.toString());
}
}