I am trying to use Hibernate 3.0 + MySQL for a demo application. However, I got a problem for the syntax of my query. A simple example would be to list all the event from Events table. From some tutorial, the following code would bring you all the events:
List result = session.createQuery("from events").list();
However, I always got exception saying checking syntax around "from" for SQL statement! Obviously MySQL doesn't like the syntax, but I could not use "select * from events" for my query either (Hibernate will complain this time).
you do not query tables in hibernate. you kind of query for objects. so unless you have a class called "events" your HQL query is wrong. you need to specify the classname instead of the table. you should be able to write HQL queries without knowing anything about tables and columns the objects are mapped to. try
you can also turn on loggin to show the generated SQL to see what SQL statements are created by hibernate. this can also help.
you can have a look at the HQL BNF to see if you have a valid query.