title: hibernate 3 with mysql
body: <p>i am using hibernate version 3.6.4 final and mysql workbench and tomcat 7 , my error is resource: HibernateClasses.Book not found when i am trying to run the main class 
  here is java test class</p>
  
  <pre><code>package Controller;
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  
  import HibernateClasses.Book;
  
  
  public class test {
  
  /**
   * @param args
   */
      public static void main(String[] args) {
      Book book = new Book();
      book.setBookId(1);
      SessionFactory sessionfactory = new Configuration().configure().buildSessionFactory();
      Session session = sessionfactory.openSession();
      session.beginTransaction();
      session.save(book);
      session.getTransaction().commit();
  }
  
   }
  </code></pre>
  
  <p>and the XML file hibernate.cfg.xml</p>
  
  <pre><code> &lt;!--
   ~ Hibernate, Relational Persistence for Idiomatic Java
    ~
    ~ Copyright (c) 2010, Red Hat Inc. or third-party contributors as
    ~ indicated by the @author tags or express copyright attribution
    ~ statements applied by the authors.  All third-party contributions are
    ~ distributed under license by Red Hat Inc.
    ~
    ~ This copyrighted material is made available to anyone wishing to use, modify,
    ~ copy, or redistribute it subject to the terms and conditions of the GNU
   ~ Lesser General Public License, as published by the Free Software Foundation.
    ~
    ~ This program is distributed in the hope that it will be useful,
    ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   ~ or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
    ~ for more details.
     ~
    ~ You should have received a copy of the GNU Lesser General Public License
    ~ along with this distribution; if not, write to:
     ~ Free Software Foundation, Inc.
     ~ 51 Franklin Street, Fifth Floor
    ~  Boston, MA  02110-1301  USA
    --&gt;
   &lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
   &lt;hibernate-configuration&gt;
  
  &lt;session-factory&gt;
  
      &lt;!-- Database connection settings --&gt;
      &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/archive&lt;/property&gt;
      &lt;property name="connection.username"&gt;root&lt;/property&gt;
      &lt;property name="connection.password"/&gt;
  
      &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
      &lt;!-- SQL dialect --&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
      &lt;!-- Disable the second-level cache  --&gt;
      &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup --&gt;
      &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
  
      &lt;mapping resource="HibernateClasses.Book"/&gt;
  
     &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>and the book class Book.java</p>
  
  <pre><code>  package HibernateClasses;
  
   import java.util.Date;
  
   import javax.persistence.Entity;
   import javax.persistence.Id;
   import javax.persistence.Lob;
   import javax.persistence.NamedNativeQueries;
   import javax.persistence.NamedNativeQuery;
  
    @Entity
    @NamedNativeQueries({
  @NamedNativeQuery(name="Book.byId",query="Select * from book where bookId=?",resultClass=Book.class),
  @NamedNativeQuery(name="Book.all",query="Select * from book ",resultClass=Book.class)
  
    })
       public class Book {
  
  @Id
  private int bookId;
  private String reference;
  private Date date;
  private String bookSubject;
  @Lob
  private String bookNote;
  private String bookfrom;
  private String bookto;
  @Lob
  private String notes;
  
  public int getBookId() {
      return bookId;
  }
  
  public void setBookId(int bookId) {
      this.bookId = bookId;
  }
  
  public String getReference() {
      return reference;
  }
  
  public void setReference(String reference) {
      this.reference = reference;
  }
  
  public Date getDate() {
      return date;
  }
  
  public void setDate(Date date) {
      this.date = date;
  }
  
  public String getBookSubject() {
      return bookSubject;
  }
  
  public void setBookSubject(String bookSubject) {
      this.bookSubject = bookSubject;
  }
  
  public String getBookNote() {
      return bookNote;
  }
  
  public void setBookNote(String bookNote) {
      this.bookNote = bookNote;
  }
  
  public String getBookfrom() {
      return bookfrom;
  }
  
  public void setBookfrom(String bookfrom) {
      this.bookfrom = bookfrom;
  }
  
  public String getBookto() {
      return bookto;
  }
  
  public void setBookto(String bookto) {
      this.bookto = bookto;
  }
  
  public String getNotes() {
      return notes;
  }
  
  public void setNotes(String notes) {
      this.notes = notes;
  }
  
        }
  </code></pre>