Interface JpaCompliance
-
- All Known Subinterfaces:
MutableJpaCompliance
- All Known Implementing Classes:
JpaComplianceImpl,MutableJpaComplianceImpl
public interface JpaComplianceEncapsulates settings controlling whether Hibernate complies strictly with certain debatable strictures of the JPA specification.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleanisGlobalGeneratorScopeEnabled()Should the scope ofTableGenerator.name()andSequenceGenerator.name()be considered globally or locally defined?booleanisJpaCacheComplianceEnabled()Should Hibernate comply with all aspects of caching as defined by JPA? Or can it deviate to perform things it believes will be "better"?booleanisJpaCascadeComplianceEnabled()JPA specifies that aCascadeType.PERSISToperation should occur at flush time.booleanisJpaClosedComplianceEnabled()JPA defines specific exceptions on specific methods when called onEntityManagerandEntityManagerFactorywhen those objects have been closed.booleanisJpaListComplianceEnabled()Deprecated.UseMappingSettings.DEFAULT_LIST_SEMANTICSinsteadbooleanisJpaOrderByMappingComplianceEnabled()Should we strictly handleOrderByexpressions?booleanisJpaProxyComplianceEnabled()JPA spec says that anEntityNotFoundExceptionshould be thrown when accessing an entity proxy which does not have an associated table row in the database.booleanisJpaQueryComplianceEnabled()Controls whether Hibernate's handling of JPA'sQuery(JPQL, Criteria and native-query) should strictly follow the JPA spec.booleanisJpaTransactionComplianceEnabled()Indicates that Hibernate'sTransactionshould behave as defined by the specification for JPA'sEntityTransactionsince it extends it.booleanisLoadByIdComplianceEnabled()JPA says that the id passed toEntityManager.getReference(java.lang.Class<T>, java.lang.Object)andEntityManager.find(java.lang.Class<T>, java.lang.Object)should be exactly the expected type, allowing no type coercion.
-
-
-
Method Detail
-
isJpaQueryComplianceEnabled
boolean isJpaQueryComplianceEnabled()
Controls whether Hibernate's handling of JPA'sQuery(JPQL, Criteria and native-query) should strictly follow the JPA spec. This includes parsing and translating a query as JPQL instead of HQL, as well as whether calls to theQuerymethods always throw the exceptions defined by the specification.Deviations result in an exception, if enabled.
- Returns:
trueindicates to behave in the spec-defined way- See Also:
JpaComplianceSettings.JPA_QUERY_COMPLIANCE
-
isJpaTransactionComplianceEnabled
boolean isJpaTransactionComplianceEnabled()
Indicates that Hibernate'sTransactionshould behave as defined by the specification for JPA'sEntityTransactionsince it extends it.- Returns:
trueindicates to behave in the spec-defined way- See Also:
JpaComplianceSettings.JPA_TRANSACTION_COMPLIANCE
-
isJpaListComplianceEnabled
@Deprecated(since="6.0") boolean isJpaListComplianceEnabled()
Deprecated.UseMappingSettings.DEFAULT_LIST_SEMANTICSinsteadControls how Hibernate interprets a mappedListwithout no order column specified. Historically Hibernate treats this as a "bag", which is a concept JPA does not have.- Returns:
trueindicates to behave in the spec-defined way, interpreting the mapping as a "list", rather than a "bag"- See Also:
JpaComplianceSettings.JPA_LIST_COMPLIANCE
-
isJpaClosedComplianceEnabled
boolean isJpaClosedComplianceEnabled()
JPA defines specific exceptions on specific methods when called onEntityManagerandEntityManagerFactorywhen those objects have been closed. This setting controls whether the spec defined behavior or Hibernate's behavior will be used.If enabled Hibernate will operate in the JPA specified way throwing exceptions when the spec says it should with regard to close checking
- Returns:
trueindicates to behave in the spec-defined way- See Also:
JpaComplianceSettings.JPA_CLOSED_COMPLIANCE
-
isJpaCascadeComplianceEnabled
boolean isJpaCascadeComplianceEnabled()
JPA specifies that aCascadeType.PERSISToperation should occur at flush time. The legacy behavior of Hibernate was aCascadeType.SAVE_UPDATE.- Returns:
trueindicates to behave in the spec-defined way- See Also:
JpaComplianceSettings.JPA_CASCADE_COMPLIANCE
-
isJpaProxyComplianceEnabled
boolean isJpaProxyComplianceEnabled()
JPA spec says that anEntityNotFoundExceptionshould be thrown when accessing an entity proxy which does not have an associated table row in the database.Traditionally, Hibernate does not initialize an entity Proxy when accessing its identifier since we already know the identifier value, hence we can save a database round trip.
If enabled Hibernate will initialize the entity proxy even when accessing its identifier.
- Returns:
trueindicates to behave in the spec-defined way- See Also:
JpaComplianceSettings.JPA_PROXY_COMPLIANCE
-
isJpaCacheComplianceEnabled
boolean isJpaCacheComplianceEnabled()
Should Hibernate comply with all aspects of caching as defined by JPA? Or can it deviate to perform things it believes will be "better"?- Returns:
trueindicates to behave in the spec-defined way- See Also:
JpaComplianceSettings.JPA_CACHING_COMPLIANCE,AbstractEntityPersister.isCacheInvalidationRequired()- Implementation Note:
- Effects include marking all secondary tables as non-optional. The reason being that optional secondary tables can lead to entity cache being invalidated rather than updated.
-
isGlobalGeneratorScopeEnabled
boolean isGlobalGeneratorScopeEnabled()
Should the scope ofTableGenerator.name()andSequenceGenerator.name()be considered globally or locally defined?- Returns:
trueif the generator name scope is considered global- See Also:
JpaComplianceSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE
-
isJpaOrderByMappingComplianceEnabled
boolean isJpaOrderByMappingComplianceEnabled()
Should we strictly handleOrderByexpressions?JPA says the order-items can only be attribute references whereas Hibernate supports a wide range of items. With this enabled, Hibernate will throw a compliance error when a non-attribute-reference is used.
-
isLoadByIdComplianceEnabled
boolean isLoadByIdComplianceEnabled()
JPA says that the id passed toEntityManager.getReference(java.lang.Class<T>, java.lang.Object)andEntityManager.find(java.lang.Class<T>, java.lang.Object)should be exactly the expected type, allowing no type coercion.Historically, Hibernate behaved the same way. Since 6.0 however, Hibernate has the ability to coerce the passed type to the expected type. For example, an
Integermay be widened toLong. Coercion is performed by callingJavaType.coerce(X, org.hibernate.type.descriptor.java.JavaType.CoercionContext).This setting controls whether such coercion should be allowed.
- Since:
- 6.0
- See Also:
JpaComplianceSettings.JPA_LOAD_BY_ID_COMPLIANCE
-
-