title: Hibernate user lacks privilege or object not found error
body: <p>I have created a java application which will select ceratin values from the table and print it using hibernate.I have used HSQLDb as the back end.But after executing I am getting the error 
  user lacks privilege or object not found:
  But iam getting the query when i execute for the first time as</p>
  
  <p>Hibernate: select ifmain0_.IF_ID as IF1_0_, ifmain0_.IF_NAME as IF2_0_ from IF_MAIN  ifmain0_</p>
  
  <p>But after that i am getting the above error. So i deleted the sample.lck file and after executing two times again I am getting the same error</p>
  
  <p>ERROR org.hibernate.util.JDBCExceptionReporter - user lacks privilege or object not found: IF_MAIN</p>
  
  <pre><code>org.hibernate.exception.SQLGrammarException: could not execute query
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      at org.hibernate.loader.Loader.doList(Loader.java:2545)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
      at org.hibernate.loader.Loader.list(Loader.java:2271)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:459)
      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:365)
      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
      at org.mock.Mainclass.listNAMES(Mainclass.java:31)
      at org.mock.Mainclass.main(Mainclass.java:22)
  Caused by: java.sql.SQLException: user lacks privilege or object not found: IF_MAIN
      at org.hsqldb.jdbc.Util.sqlException(Util.java:224)
      at org.hsqldb.jdbc.JDBCPreparedStatement.&lt;init&gt;(JDBCPreparedStatement.java:3885)
      at org.hsqldb.jdbc.JDBCConnection.prepareStatement(JDBCConnection.java:641)
      at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
      at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
      at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
      at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700)
      at org.hibernate.loader.Loader.doQuery(Loader.java:801)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
      at org.hibernate.loader.Loader.doList(Loader.java:2542)
      ... 9 more
  Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: IF_MAIN
      at org.hsqldb.error.Error.error(Error.java:77)
      at org.hsqldb.SchemaManager.getTable(SchemaManager.java:685)
      at org.hsqldb.ParserDQL.readTableName(ParserDQL.java:5297)
      at org.hsqldb.ParserDQL.readTableOrSubquery(ParserDQL.java:1662)
      at org.hsqldb.ParserDQL.XreadTableReference(ParserDQL.java:1074)
      at org.hsqldb.ParserDQL.XreadFromClause(ParserDQL.java:1061)
      at org.hsqldb.ParserDQL.XreadTableExpression(ParserDQL.java:996)
      at org.hsqldb.ParserDQL.XreadQuerySpecification(ParserDQL.java:990)
      at org.hsqldb.ParserDQL.XreadSimpleTable(ParserDQL.java:974)
      at org.hsqldb.ParserDQL.XreadQueryPrimary(ParserDQL.java:903)
      at org.hsqldb.ParserDQL.XreadQueryTerm(ParserDQL.java:869)
      at org.hsqldb.ParserDQL.XreadQueryExpressionBody(ParserDQL.java:848)
      at org.hsqldb.ParserDQL.XreadQueryExpression(ParserDQL.java:822)
      at org.hsqldb.ParserDQL.compileCursorSpecification(ParserDQL.java:5449)
      at org.hsqldb.ParserCommand.compilePart(ParserCommand.java:133)
      at org.hsqldb.ParserCommand.compileStatement(ParserCommand.java:63)
      at org.hsqldb.Session.compileStatement(Session.java:906)
      at org.hsqldb.StatementManager.compile(StatementManager.java:335)
      at org.hsqldb.Session.execute(Session.java:1009)
      at org.hsqldb.jdbc.JDBCPreparedStatement.&lt;init&gt;(JDBCPreparedStatement.java:3882)
  
  
  
  
  
  My hibernate config file is 
  </code></pre>
  
  <p>
  
  
      
          org.hsqldb.jdbcDriver
          jdbc:hsqldb:file:C:/Users/298637/SAMPLE;hsqldb.lock_file=false
          org.hibernate.dialect.HSQLDialect
          sa
          sa
          1
          thread
          org.hibernate.cache.NoCacheProvider
          true
          none
          
      
  </p>
  
  <p>Mapping file is </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC 
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt; 
  
  &lt;hibernate-mapping package="org.mock"&gt;
     &lt;class name="IFMAIN" table="IF_MAIN "&gt;
        &lt;meta attribute="class-description"&gt;
           This class contains the employee detail. 
        &lt;/meta&gt;
        &lt;id name="number" type="string" column="IF_ID"&gt;
           &lt;generator class="native"/&gt;
        &lt;/id&gt;
        &lt;property name="name" column="IF_NAME" type="string"/&gt;
     &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Pojo CLASS</p>
  
  <pre><code>public class IFMAIN {
      private String number;
      private String name ;
      public IFMAIN()
      {
  
      }
      public String getNumber() {
          return number;
      }
      public void setNumber(String number) {
          this.number = number;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  
  }
  </code></pre>
  
  <p>Main class</p>
  
  <pre><code>import java.util.Iterator;
  import java.util.List;
  import org.hibernate.HibernateException;
  import org.hibernate.Query;
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.hibernate.cfg.Configuration;
  
  public class Mainclass {
       private static SessionFactory factory; 
         public static void main(String[] args) {
            try{
               factory = new Configuration().configure().buildSessionFactory();
            }catch (Throwable ex) { 
               System.err.println("Failed to create sessionFactory object." + ex);
               throw new ExceptionInInitializerError(ex); 
            }
            Mainclass ME = new Mainclass();
            ME.listNAMES();
  }
  
  
  public void listNAMES( ){
     Session session = factory.openSession();
     Transaction tx = null;
     try{
        tx = session.beginTransaction();
        List sample = session.createQuery("FROM IFMAIN").list();
        int i=0;
        for (Iterator iterator = sample.iterator(); iterator.hasNext();){
           IFMAIN count = (IFMAIN) iterator.next(); 
           System.out.println("SITE CODE: " + count.getNumber()); 
           System.out.println("SITE DESCRIPTION: " + count.getName());  
        }
  
        tx.commit();
     }catch (HibernateException e) {
        if (tx!=null) tx.rollback();
        e.printStackTrace(); 
     }finally {
        session.close(); 
     }
  }
  }
  </code></pre>
  
  <p>Can anybody tell me why I am getting this error. I tried with other db like mysql and oracle 10g. there Iam able to connect and get the result but when I am using the HSQL Db I am getting this error </p>