-->
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.  [ 9 posts ] 
Author Message
 Post subject: Error with "Delete" Method. Plz Help!!!
PostPosted: Mon Jan 30, 2006 3:25 am 
Newbie

Joined: Fri Jan 27, 2006 10:27 am
Posts: 13
Hello Everyone,

When i try to delete a row from the table as,

Customer c1 = new Customer();
c1.CustomerID = "A001";

session.Delete("from customers where customerid = ",c1.CustomerID,NHibernate.NHibernateUtil.String);

I get the following Exception:

"in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query)"

My table name is "customers".

Anyone Plz help to solve this.

Thanks in Advance,
Dhivya.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 6:40 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You need to use class names in HQL queries (Delete takes an HQL query). Delete("from Customer c where c.id = ?", c1.CustomerID, NHibernateUtil.String)

or just Delete(c1) should work I think.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 7:40 am 
Newbie

Joined: Fri Jan 27, 2006 10:27 am
Posts: 13
Hi Sergey,

Thanks for your fast response.

I am able to use Delete(c1).

But when i try to Delete using HQL query:
Delete("from customers c where c.id =?",c1.Cid,NHibernateUtil.String)

again i get exception as:
"in expected: c [from customers c where c.customerid =?]"


And also, i could not find, executeUpdate Method with the below statement:
session.createQuery( "delete Customers c where c.id = 1 ).executeUpdate();

Plz help.


Thanks,
Dhivya.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 8:28 am 
Newbie

Joined: Fri Jan 27, 2006 10:27 am
Posts: 13
Hi Sergey,

Thanks for your fast response.

I am able to use Delete(c1).

But when i try to Delete using HQL query:
Delete("from customers c where c.id =?",c1.Cid,NHibernateUtil.String)

again i get exception as:
"in expected: c [from customers c where c.customerid =?]"


And also, i could not find, executeUpdate Method with the below statement:
session.createQuery( "delete Customers c where c.id = 1 ).executeUpdate();

Plz help.


Thanks,
Dhivya.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 3:09 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Please read my reply carefully again, you should see your error.
There isn't a method named executeUpdate because it's a Hibernate 3 feature and NHibernate is a port of Hibernate 2.1.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 31, 2006 3:30 am 
Newbie

Joined: Fri Jan 27, 2006 10:27 am
Posts: 13
Thanks a lot Sergey.
Now Delete Method works fine.

1.If there is no method called executeUpdate...then how is it possible to use the CreateQuery Method?

2.Is there any way to execute Stored Procedures using NHibernate?


Plz Help.

Thanks,
Dhivya.


Top
 Profile  
 
 Post subject: SP
PostPosted: Tue Jan 31, 2006 3:44 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I think you call query.List (or some method similar to that) to execute the Query returned from CreateQuery.

You cannot execute SP's using NHibernate. However you can extend NH to do this. Please search the forum, there was a post sometime ago on how to do this. This facility is already available out of the box in 3.0 for java users.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 6:10 am 
Newbie

Joined: Fri Jan 27, 2006 10:27 am
Posts: 13
It worked fine.
Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 6:11 am 
Newbie

Joined: Fri Jan 27, 2006 10:27 am
Posts: 13
It worked fine.
Thanks a lot.


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