ResetEjb.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:testing_security_development_enterprise_systems 作者:
private 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();
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号