-->
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.  [ 5 posts ] 
Author Message
 Post subject: ERROR: <object> is not mapped
PostPosted: Thu Aug 25, 2005 11:52 am 
Newbie

Joined: Thu Aug 25, 2005 10:07 am
Posts: 3
Hi, I am trying to get my first hibernate application working. Following the doc, i have a pojo class Category and a table with the same name.

1. i have the mapping added in element <session-factory> in hibernate.cfg.xml
2. I have category.hbm.xml with following entry for mapping
<class name="Category" table="CATEGORY">
<id name="categoryid" type="int" unsaved-value="null">
<column name="categoryid" sql-gtype="int" not-null="true"/>
</id>
....
</class>
3. I have program snippet

Session sess = HibernateUtil.currentSession();
Transaction tx = sess.beginTransaction();
Category cat = new Category();

Query query = sess.createQuery("select c from category as c where c.categoryid = :id");
query.setInteger("id", 1);

for(Iterator it = query.iterate(); it.hasNext();)
{
cat = (Category)it.next();
out.prntln("category " + cat.getCategoryName());
}

But i got error:

ERROR: category is no mapped
ERROR: invalid path: c.categoryid'

I got the CAT working following the document and i use the same hibernate.cfg.xml, also category.hbm.xml is modified based on CAT.hbm.xml.

Could any one tell me which part is missing in my config?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 12:00 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
HQL is case sensitive. Try Category instead of category in your query.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 12:28 pm 
Newbie

Joined: Thu Aug 25, 2005 10:07 am
Posts: 3
yes. i changed "category" to "Category" in the query:
select c from category as c where c.categoryid = :id to
select c from Category as c where c.categoryid = :id

But this really does not make much sense to me.

IS the category here referred in the query the java object instead of table?
sql is not case sensitive.

Can anybody explain?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 12:28 pm 
Newbie

Joined: Thu Aug 25, 2005 10:07 am
Posts: 3
liux99 wrote:
yes. i changed "category" to "Category" in the query:
select c from category as c where c.categoryid = :id to
select c from Category as c where c.categoryid = :id

this works.

But this really does not make much sense to me.

IS the category here referred in the query the java object instead of table?
sql is not case sensitive.

Can anybody explain?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 12:32 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
Think of HQL as an object-oriented query language.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.