-->
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: Hi and Regards To Everyone:-Problem in deleting Rows
PostPosted: Wed Apr 18, 2007 1:27 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 12:04 pm
Posts: 25
Location: Chennai
Hi

Greetings!

Could anybody help me out for following query.

By running below code i m being able to delete the row where bookid=12.

long bookid = 12;
Session sess = HibernateFactory.currentSession();
Object book = sess.load(Book.class, bookid);
sess.delete(book);


now i want to delete the row based on any other column of the table which is not the primary key for that table.

Like could u get me the code for below query in the same way..

delete from tablename where bookname="abc";


Note:-Bookname is not the primary key.


Thanks.

With Regards
Saurav Jain

_________________
I Really want to share my knowledge and learn from you all people specaily about Hibernate.. Thanks Lot


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 8:39 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
Something like this should help

Query query = sess.createQuery("from Book as b where b.bookName = ?");
query.setParameter(0, "abc", Hibernate.STRING);
List result = query.list();
Object book = result.get(0);
sess.delete(book);


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.