Are SQL injection attacks possible in JPA?

前端 未结 4 796
滥情空心
滥情空心 2020-12-08 04:05

I\'m building a Java Web Application using Java EE 6 and JSF-2.0, using the persistence API for all database operations.

The back-end is MySQL, but I have used the

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 04:36

    It's only possible if you're inlining user-controlled variables in a SQL/JPQL string like so:

    String sql = "SELECT u FROM User u WHERE id=" + id;
    

    If you aren't doing that and are using parameterized/named queries only, then you're safe.

提交回复
热议问题