Hibernate ORM 7.2
Last reviewed Oct 11, 2026
Prompt Details
Prompt Composition
2prompts
- Java 17109 lines · 4.4K tokens
- Hibernate ORM 7.274 lines · 2.3K tokens
Total183 lines · 6.8K tokens
CWE Coverage
- 20
- 22
- 59
- 78
- 79
- 88
- 89
- 90
- 95
- 117
- 190
- 201
- 208
- 209
- 214
- 250
- 287
- 295
- 297
- 323
- 327
- 338
- 347
- 354
- 362
- 367
- 378
- 427
- 459
- 470
- 471
- 494
- 502
- 532
- 611
- 639
- 653
- 732
- 770
- 772
- 776
- 807
- 829
- 862
- 863
- 915
- 916
- 918
- 922
Prompt Preview
Apply the Java 17 baseline first. These rules cover Hibernate ORM 7.2.24.Final, which runs on JDK 17, 21, or 25 and implements Jakarta Persistence 3.2.
Queries
- Pass every request-derived value as a named or ordinal parameter of
createQuery,createSelectionQuery,createMutationQuery, orcreateNativeQuery; concatenated query text bypasses binding. - Keep
hibernate.criteria.value_handling_modeat itsbinddefault;inlinerenders implicit criteria values as SQL literals, while explicitCriteriaBuilder.parameter()arguments stay bound either way. - Never pass user input to
CriteriaBuilder.literal(), which inlines its argument even inbindmode. - Express dynamic filtering with 7.x
Restrictionfactories onSelectionSpecificationandMutationSpecification, not HQL fragments glued from request fields. - Sort with
Order.asc(SingularAttribute)from the static metamodel, allowlisting the attribute name with theOrder.by(Class, String, SortDirection)overload. @SQLRestriction,@Filterconditions,@SQLSelect,@SQLInsert,@SQLUpdate,@SQLDelete, and@ColumnTransformerare fixed build-time SQL; bind@ParamDeffilter arguments and use documented JDBC placeholders in custom SQL.- Keep incubating
hibernate.query.hql.json_functions_enabledandhibernate.query.hql.xml_functions_enabledoff unless needed, never building JSON or XML path arguments from request data. - Set
hibernate.query.fail_on_pagination_over_collection_fetch=true; itsfalsedefault lets a paginated collection fetch join load everything and paginate in memory.