I'm getting this unique problem from a simple query. I'm using Hibernate 2.1 and its talking to HSQL.
When I run the following statement:
Code:
session.find("from HexMail");
I get the following results:
Code:
net.sf.hibernate.JDBCException: Could not execute query
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1546)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1520)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at zarnett.hibernate.example.HexEmailRunner.main(HexEmailRunner.java:87)
Caused by: java.sql.SQLException: Unexpected token: FROM in statement [select from]
Prior to this I was doing simple calls such as:
Code:
final HexEmail retrieveEmail =
(HexEmail)session.load(HexEmail.class,generatedID);
which all worked fine.
My mapping file is pretty simple and looks as follows:
Code:
<hibernate-mapping>
<class name="zarnett.hibernate.example.HexEmail" table="HexMail">
<id name="emailID" column="EmailID" type="integer" unsaved-value="0">
<generator class="increment"/>
</id>
<property name="message">
<column name="Message" length="1000" not-null="true"/>
</property>
</class>
</hibernate-mapping>
As well, when I create my session I am doing the following:
Code:
// Allow hibernate to load a mapping file using getResourceAsStream()
Configuration config = new Configuration();
config.addClass(zarnett.hibernate.example.HexEmail.class);
sessionFactory = config.buildSessionFactory();
By the time I have made this call I have done several transactions including a save, several retrievals (including retrievals on rows that do not exist). I have not closed the session yet either.
Any ideas on what's wrong?
As well, when I do something like
Code:
"from HexEmail as hm where hm.EmailId=?"
It says it was not expecting the "as" clause.
Thanks in advance for any help!