-->
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: how to do delete by criteria
PostPosted: Tue Apr 06, 2010 7:12 am 
Newbie

Joined: Tue Apr 06, 2010 6:44 am
Posts: 2
i do not know how to delete a row by using criteria.

i have to solve the query in criteria.

"delete employee_name from employee where eid=1"


please tell the answer.

thanks


Top
 Profile  
 
 Post subject: Re: how to do delete by criteria
PostPosted: Tue Apr 06, 2010 8:35 am 
Beginner
Beginner

Joined: Fri Aug 24, 2007 9:47 am
Posts: 21
with hql
Code :

String hql = "delete from League where league_name = :name";
session.createQuery(hql).setString("name", name).executeUpdate();



with criteria
Code :

League league = (League) session.createCriteria(League.class).add(Restrictions.eq("name", name) ).uniqueResult();
session.delete(league);

_________________
recherche-programmeur.fr


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.