-->
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: hibernate exception : in expected
PostPosted: Tue Oct 03, 2006 8:43 am 
Newbie

Joined: Tue Oct 03, 2006 8:36 am
Posts: 3
I am new to hibernate and while working on the following program i am getting the
"in expected: item [SELECT item.item_id,item.purchase_id,item.serial from items item]' exception.

try
{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();

//Create Select Clause HQL
String SQL_QUERY ="SELECT item.item_id,item.purchase_id,item.serial from items item";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate();it.hasNext();){
Object[] row = (Object[]) it.next();
System.out.println("ID: " + row[0]);
System.out.println("Name: " + row[1]);
System.out.println("Amount: " + row[2]);
}
session.close();
}catch(Exception e)
{
System.out.println(e.getMessage());
}
finally
{
}

I chked it and know tht the query is correct but i am getting the same problem again. can anyone help me?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 04, 2006 3:37 am 
Newbie

Joined: Fri Sep 29, 2006 10:17 am
Posts: 4
Hi Swarupa

The first tihing i would check is the casing of item, HQL is case sencitive, so if your class item is really Item (whit a big I) then you should write it like that instead.

The same goes for properties, and properties are the properties of the actual object , not the names of columns in the database.

So tjeck that the properties of item is called item_id, purchase_id ....
and not something like purchaseId.

Regards
Timm


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.