To Persistence Gurus: JPA and Hibernate with HSQLDB

Hello Gurus,
I am new with setting up a database, but for a day now, I have the auto generate hiberenate code working somewhat and connect to my HSQLDB database. The issue that I am having is that I am getting an error in the log with the for loop in the main that is auto generated by IntelliJ that includes:


final Query query = session.createQuery("from " + entityName);
                System.out.println("executing: " + query.getQueryString());
                for (Object o : query.list()) {
                    System.out.println("  " + o);




Caused by: java.sql.SQLException: Table not found in statement [select marioncrme0_.id as id0_, marioncrme0_.courseName as courseName0_, marioncrme0_.courseNumber as courseNu3_0_, marioncrme0_.c


My Class:

@javax.persistence.Table(name = "CRM", schema = "PUBLIC", catalog = "")
@Entity
public class MarionCrmEntity




Is this a dialect issue or what? It seems like it it is querying wrong with an usual syntax maybe... Do i need to set up or change my hibernate config file?


Hibernate config:

<hibernate-configuration>
    <session-factory>
        <property name="connection.url"><![CDATA[jdbc:hsqldb:file:./test]]></property>
        <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="connection.username">SA</property>
        <property name="connection.password"></property>


        <mapping />
        <!-- DB schema will be updated if needed -->
        <!-- <property name="hbm2ddl.auto">update</property> -->
    </session-factory>




Persitence file:

  <persistence-unit name="TestUnit">
        <class>db.MarionCrmEntity</class>
        <properties>
            <property name="hibernate.connection.url" value="jdbc:hsqldb:file:./test"/>
            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
            <property name="hibernate.connection.username" value="SA"/>
            <property name="hibernate.connection.password" value=""/>
        </properties>
    </persistence-unit>



Thanks for any help, and I love Intellij!!!
1 comment

The message means HSQLDB cannot find the table specified.
If you use the database in "in-memory" mode you are to recreate schema on each run.
hbm2ddl.auto property may help you in this case.

You may check the existence of th PUBLIC.CRM table using database console (Ctrl-Shift-F10 in Database toolwindow).
Or simply by opening a table editor.

0

Please sign in to leave a comment.