I am getting the following error when I try to run my first hibernate example, (for the sake of brevity I have reduced error and class text):
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: Business is not mapped [from Business]
My Mapping file generated from hibernate tools contains:
<?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 Jun 7, 2007 9:39:59 AM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="Business" table="BUSINESS" schema="PRD">
<id name="orgId" type="big_decimal">
<column name="ORG_ID" precision="32" scale="0" />
<generator class="assigned" />
</id>
My POJO created from hibernate tools contains:
package gov.mt.dli.erd.clm;
// default package
// Generated Jun 7, 2007 9:39:59 AM by Hibernate Tools 3.2.0.b9
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
/**
* Business generated by hbm2java
*/
public class Business implements java.io.Serializable {
private BigDecimal orgId;
My FirstExample class contains:
package gov.mt.dli.erd.clm;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class FirstExample
{
public static void main(String[] args)
{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
//session = InitSessionFactory.getInstance().getCurrentSession();
Transaction tx = session.beginTransaction();
List result = session.createQuery("from Business").list();
Iterator iter = result.iterator();
while (iter.hasNext())
{
Business aBusiness = (Business)iter.next();
System.out.println("Name: " +
aBusiness.getBusName());
}
tx.commit();
session.close();
}
}
Any help on how to resolve this will be appreciated!
|