-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: is not mapped --- Error
PostPosted: Tue Jun 12, 2007 6:36 pm 
Newbie

Joined: Sat Jun 09, 2007 12:36 am
Posts: 6
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!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 12:23 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
Add your mapping to hibernate.cfg.xml
( <mapping resource="business.hbm.xml"/> )

-----------------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.