public void deleteEntities(Class<?> entity){
if(entity == null || entity.getAnnotation(Entity.class) == null){
throw new IllegalArgumentException("Invalid non-entity class");
}
String name = entity.getSimpleName();
/*
Note: we passed as input a Class<?> instead of a String to
avoid SQL injection. However, being here just test code, it should
not be a problem. But, as a good habit, always be paranoiac about
security, above all when you have code that can delete the whole
database...
*/
Query query = em.createQuery("delete from " + name);
query.executeUpdate();
}
DeleterEJB.java 文件源码
java
阅读 37
收藏 0
点赞 0
评论 0
项目:testing_security_development_enterprise_systems
作者:
评论列表
文章目录