I am trying to delete all rows in table 'user_role' with hibernate query. But every time i am getting errors. Can someone please help me with it.
DaoImpl
@Override
public void deleteAll() {
session.getCurrentSession().delete(/*delete all query*/);
}
model class
@Entity @Table(name="user_role")
public class User_Role {
@Id @Column @GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@Column(name="role_name")
private String name;
//setter and getter
}
try this:
sessionFactory.getCurrentSession().createQuery("delete from User_Role").executeUpdate();