Why Hibernate inlines Integer parameter list passed to JPA Criteria Query?

前端 未结 4 683
南方客
南方客 2020-12-16 15:12

I am building a query using JPA Criteria API. When I created two restriction predicates using javax.persistence.criteria.Path#in(Collection) method the

4条回答
  •  没有蜡笔的小新
    2020-12-16 16:03

    1. Because Strings can contain SQL and Integers cannot, there is no need to from a security aspect (SQL injection).
    2. The JPA spec doesn't specify it as explicit as you would like it to be. It seems to be an implementation details.
    3. Prepared statement parameters for String parameters. For int parameters it doesn't matter since they cannot be misused by hackers.
    4. YES
    5. You should look that up in the documentation of the specific database you're using. JPA does not care about such things.
    6. Why? What are the benefits? Don't try to improve things when you don't know what you're improving.

提交回复
热议问题