- This topic has 5 replies, 2 voices, and was last updated 19 years, 5 months ago by Riyad Kalla.
-
AuthorPosts
-
bradmMemberWhile 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());
}
}
Riyad KallaMemberWhile the online tutorial
Which tut?
what is there about the following attempt to SEARCH the authors table that is wrong?
Please paste the entire stack trace, also can you please post all the information we request in the [URL=http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-393.html]Posting Guidelines[/URL] thread at the top of this forum? That will give us some context so that we can determine if this is an installation issue, a configuration problem, or a bug. Thanks.
Additionally, what DB and dialect are you using in your hibernate.cfg.xml file?
bradmMemberI’m using Eclipse 3.1M6; MyEclipse 3.8.4. The tutorial I’m looking at is at http://myeclipseide.com/enterpriseworkbench/help/index.jsp?topic=/com.genuitec.myeclipse.doc/html/quickstarts/hibernate/index.html
The errors I get are as follows:
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
net.sf.hibernate.exception.SQLGrammarException: Could not execute query
Riyad KallaMemberAdditionally, what DB and dialect are you using in your hibernate.cfg.xml file?
bradmMemberYIKES I’m an idiot: excuse the interruption (I just found the problem and it’s nobody’s fault but mine)
Riyad KallaMemberCould you post the solution? Everyone runs into all different kinds of problems and even the smallest fix can sometimes help or atleast get someone on the right track when they read it.
Thank you in advance.
-
AuthorPosts