Class MutableJpaComplianceImpl
- All Implemented Interfaces:
JpaCompliance
,MutableJpaCompliance
-
Constructor Summary
ConstructorsConstructorDescriptionMutableJpaComplianceImpl
(Map<?, ?> configurationSettings) MutableJpaComplianceImpl
(Map<?, ?> configurationSettings, boolean jpaByDefault) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Should the scope ofTableGenerator.name()
andSequenceGenerator.name()
be considered globally or locally defined?boolean
Should Hibernate comply with all aspects of caching as defined by JPA? Or can it deviate to perform things it believes will be "better"?boolean
boolean
JPA defines specific exceptions on specific methods when called onEntityManager
andEntityManagerFactory
when those objects have been closed.boolean
Should we strictly handleOrderBy
expressions?boolean
JPA spec says that anEntityNotFoundException
should be thrown when accessing an entity proxy which does not have an associated table row in the database.boolean
Controls whether Hibernate's handling of JPA'sQuery
(JPQL, Criteria and native-query) should strictly follow the JPA spec.boolean
Indicates that Hibernate'sTransaction
should behave as defined by the specification for JPA'sEntityTransaction
since it extends it.boolean
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.void
setCachingCompliance
(boolean cachingCompliance) void
setCascadeCompliance
(boolean cascadeCompliance) void
setClosedCompliance
(boolean closedCompliance) void
setGeneratorNameScopeCompliance
(boolean enabled) void
setLoadByIdCompliance
(boolean enabled) void
setOrderByMappingCompliance
(boolean orderByMappingCompliance) void
setProxyCompliance
(boolean proxyCompliance) void
setQueryCompliance
(boolean queryCompliance) void
setTransactionCompliance
(boolean transactionCompliance)
-
Constructor Details
-
MutableJpaComplianceImpl
-
MutableJpaComplianceImpl
-
-
Method Details
-
isJpaQueryComplianceEnabled
public boolean isJpaQueryComplianceEnabled()Description copied from interface:JpaCompliance
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 theQuery
methods always throw the exceptions defined by the specification.Deviations result in an exception, if enabled.
- Specified by:
isJpaQueryComplianceEnabled
in interfaceJpaCompliance
- Returns:
true
indicates to behave in the spec-defined way- See Also:
-
isJpaTransactionComplianceEnabled
public boolean isJpaTransactionComplianceEnabled()Description copied from interface:JpaCompliance
Indicates that Hibernate'sTransaction
should behave as defined by the specification for JPA'sEntityTransaction
since it extends it.- Specified by:
isJpaTransactionComplianceEnabled
in interfaceJpaCompliance
- Returns:
true
indicates to behave in the spec-defined way- See Also:
-
isJpaCascadeComplianceEnabled
public boolean isJpaCascadeComplianceEnabled()- Specified by:
isJpaCascadeComplianceEnabled
in interfaceJpaCompliance
-
isJpaClosedComplianceEnabled
public boolean isJpaClosedComplianceEnabled()Description copied from interface:JpaCompliance
JPA defines specific exceptions on specific methods when called onEntityManager
andEntityManagerFactory
when 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
- Specified by:
isJpaClosedComplianceEnabled
in interfaceJpaCompliance
- Returns:
true
indicates to behave in the spec-defined way- See Also:
-
isJpaProxyComplianceEnabled
public boolean isJpaProxyComplianceEnabled()Description copied from interface:JpaCompliance
JPA spec says that anEntityNotFoundException
should 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.
- Specified by:
isJpaProxyComplianceEnabled
in interfaceJpaCompliance
- Returns:
true
indicates to behave in the spec-defined way- See Also:
-
isJpaCacheComplianceEnabled
public boolean isJpaCacheComplianceEnabled()Description copied from interface:JpaCompliance
Should Hibernate comply with all aspects of caching as defined by JPA? Or can it deviate to perform things it believes will be "better"?- Specified by:
isJpaCacheComplianceEnabled
in interfaceJpaCompliance
- Returns:
true
indicates to behave in the spec-defined way- See Also:
-
isGlobalGeneratorScopeEnabled
public boolean isGlobalGeneratorScopeEnabled()Description copied from interface:JpaCompliance
Should the scope ofTableGenerator.name()
andSequenceGenerator.name()
be considered globally or locally defined?- Specified by:
isGlobalGeneratorScopeEnabled
in interfaceJpaCompliance
- Returns:
true
if the generator name scope is considered global- See Also:
-
isJpaOrderByMappingComplianceEnabled
public boolean isJpaOrderByMappingComplianceEnabled()Description copied from interface:JpaCompliance
Should we strictly handleOrderBy
expressions?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.
- Specified by:
isJpaOrderByMappingComplianceEnabled
in interfaceJpaCompliance
- See Also:
-
isLoadByIdComplianceEnabled
public boolean isLoadByIdComplianceEnabled()Description copied from interface:JpaCompliance
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
Integer
may 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.
- Specified by:
isLoadByIdComplianceEnabled
in interfaceJpaCompliance
- See Also:
-
setCascadeCompliance
public void setCascadeCompliance(boolean cascadeCompliance) - Specified by:
setCascadeCompliance
in interfaceMutableJpaCompliance
-
setOrderByMappingCompliance
public void setOrderByMappingCompliance(boolean orderByMappingCompliance) - Specified by:
setOrderByMappingCompliance
in interfaceMutableJpaCompliance
-
setProxyCompliance
public void setProxyCompliance(boolean proxyCompliance) - Specified by:
setProxyCompliance
in interfaceMutableJpaCompliance
-
setGeneratorNameScopeCompliance
public void setGeneratorNameScopeCompliance(boolean enabled) - Specified by:
setGeneratorNameScopeCompliance
in interfaceMutableJpaCompliance
-
setQueryCompliance
public void setQueryCompliance(boolean queryCompliance) - Specified by:
setQueryCompliance
in interfaceMutableJpaCompliance
-
setTransactionCompliance
public void setTransactionCompliance(boolean transactionCompliance) - Specified by:
setTransactionCompliance
in interfaceMutableJpaCompliance
-
setClosedCompliance
public void setClosedCompliance(boolean closedCompliance) - Specified by:
setClosedCompliance
in interfaceMutableJpaCompliance
-
setCachingCompliance
public void setCachingCompliance(boolean cachingCompliance) - Specified by:
setCachingCompliance
in interfaceMutableJpaCompliance
-
setLoadByIdCompliance
public void setLoadByIdCompliance(boolean enabled) - Specified by:
setLoadByIdCompliance
in interfaceMutableJpaCompliance
-
immutableCopy
- Specified by:
immutableCopy
in interfaceMutableJpaCompliance
-