Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate: IN clause when deleting  RSS feed

 
Antonio Fornie
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I have an entity User:

@Entity
@Proxy(lazy=false)
public class User{
@Id
int id;
protected String name;
}

I'd like to delete some users from a list of ids (List<Integer>), so I tried to use the IN clause but ot didn't work. Neither I could use a Criteria. So what I did was to use the Criteria to make a select an then delete all of them with that resultset:

this.hibernateTemplate.deleteAll(myCriteria.list());

Isn't there a better way to do it? Can't I avoid that select and use directly a delete?

Thank you very much.

Antonio
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!