I want to delete all objects by their IDs in Hibernate Generic Dao implementation.
For now I created method like this:
@Override
public void deleteByIds(Collection<Serializable> ids) {
getSession()
.createQuery("delete from " + getDomainClass() + " where id in (:ids)")
.setParameter("ids", ids)
.executeUpdate();
}
but id propery in query is undefined. It's mean I can have this method only on entities using @NamedQueries and it impossible to extract this method to Generic DAO?
Assuming
idis available in your hibernate entity, you need to changeto