Cannot map to sakila database like in NB tutorial http://netbeans.org/kb/docs/web/hibernate-webapp.htmlHi all,
I am new in Hibernate and NB IDE. I am trying to do the NB tutorial "Using Hibernate in a Web Application" from this web site "http://netbeans.org/kb/docs/web/hibernate-webapp.html#05". My problem is I get the following message
org.hibernate.hql.ast.QuerySyntaxException: film is not mapped [from film]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
when I try to test the Hibernate connection (from film) to Sakila database.
I created all the files like in the tutorial.
Here are the source codes:
---hibernate.cfg.xml---
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/sakila</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">*****</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping resource="dvdrental/Category.hbm.xml"/>
<mapping resource="dvdrental/Language.hbm.xml"/>
<mapping resource="dvdrental/FilmActor.hbm.xml"/>
<mapping resource="dvdrental/Actor.hbm.xml"/>
<mapping resource="dvdrental/Film.hbm.xml"/>
<mapping resource="dvdrental/FilmCategory.hbm.xml"/>
</session-factory>
</hibernate-configuration>
---hiberante.reveng.xml---
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
<schema-selection match-catalog="sakila"/>
<table-filter match-name="language"/>
<table-filter match-name="film_actor"/>
<table-filter match-name="actor"/>
<table-filter match-name="category"/>
<table-filter match-name="film"/>
<table-filter match-name="film_category"/>
</hibernate-reverse-engineering>
---Film.hbm.xml---
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 25.08.2010 10:00:27 by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="dvdrental.Film" table="film" catalog="sakila">
<id name="filmId" type="java.lang.Short">
<column name="film_id" />
<generator class="identity" />
</id>
<many-to-one name="languageByOriginalLanguageId" class="dvdrental.Language" fetch="select">
<column name="original_language_id" />
</many-to-one>
<many-to-one name="languageByLanguageId" class="dvdrental.Language" fetch="select">
<column name="language_id" not-null="true" />
</many-to-one>
<property name="title" type="string">
<column name="title" not-null="true" />
</property>
<property name="description" type="string">
<column name="description" length="65535" />
</property>
<property name="releaseYear" type="date">
<column name="release_year" length="0" />
</property>
<property name="rentalDuration" type="byte">
<column name="rental_duration" not-null="true" />
</property>
<property name="rentalRate" type="big_decimal">
<column name="rental_rate" precision="4" not-null="true" />
</property>
<property name="length" type="java.lang.Short">
<column name="length" />
</property>
<property name="replacementCost" type="big_decimal">
<column name="replacement_cost" precision="5" not-null="true" />
</property>
<property name="rating" type="string">
<column name="rating" length="5" />
</property>
<property name="specialFeatures" type="string">
<column name="special_features" length="54" />
</property>
<property name="lastUpdate" type="timestamp">
<column name="last_update" length="19" not-null="true" />
</property>
<set name="filmActors" inverse="true">
<key>
<column name="film_id" not-null="true" />
</key>
<one-to-many class="dvdrental.FilmActor" />
</set>
<set name="filmCategories" inverse="true">
<key>
<column name="film_id" not-null="true" />
</key>
<one-to-many class="dvdrental.FilmCategory" />
</set>
</class>
</hibernate-mapping>
---FilmHelper.java---
package dvdrental;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
/**
*
* @author Ugur Kocak
*/
public class FilmHelper {
Session session = null;
public FilmHelper() {
this.session = HibernateUtil.getSessionFactory().getCurrentSession();
}
}
Thank you all in advance for any hints
Regards
Ugur