Class JpaMapperModificationResetDomainMapperMember
java.lang.Object
com.broadleafcommerce.data.tracking.jpa.mapping.JpaMapperModificationResetDomainMapperMember
- All Implemented Interfaces:
com.broadleafcommerce.common.extension.data.DataRoutePartitionAware,com.broadleafcommerce.data.tracking.core.mapping.DomainMapper,com.broadleafcommerce.data.tracking.core.mapping.DomainMapperMember,org.springframework.core.Ordered
public class JpaMapperModificationResetDomainMapperMember
extends Object
implements com.broadleafcommerce.data.tracking.core.mapping.DomainMapperMember
Specialized
DomainMapperMember responsible for detecting if the
ModelMapperDomainMapperMember instance
will reset the identifier on the repository domain instance. If so, and a current transaction is
active, it will attempt to detach the entity from an active EntityManager on the
transaction (if an EntityManager is found to be currently managing the entity). This avoids an
issue where Hibernate complains about the id being reset for an entity during flush at or before
the transaction end. Note, the id is generally reset as a result of sandbox state detection, in
which a clone of the entity is persisted in the database for the targeted sandbox. Also note, the
ordering is intentional for this to occur before the ModelMapperDomainMapperMember has
been exercised.-
Field Summary
Fields inherited from interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
ALL_MATCHFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionJpaMapperModificationResetDomainMapperMember(com.broadleafcommerce.data.tracking.core.mapping.TrackableDomainMapperMemberSupport trackableDomainMapperMemberSupport, com.broadleafcommerce.data.tracking.core.mapping.ModelMapperDomainMapperMember modelMapperDomainMapperMember) -
Method Summary
Modifier and TypeMethodDescription<D> DdeleteMap(D repositoryDomain, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected <D> voiddetachEntityIfApplicable(D repositoryDomain, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, jakarta.persistence.EntityManager em) Remove the supplied entity instance from theEntityManagerinstance, if available.intgetOrder()<D,P> D modifyMap(D repositoryDomain, P businessDomain, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, boolean allowNull) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.mapping.DomainMapper
getBusinessDomainTypeMethods inherited from interface com.broadleafcommerce.data.tracking.core.mapping.DomainMapperMember
fromBusinessDomain, fromRepositoryDomain
-
Constructor Details
-
JpaMapperModificationResetDomainMapperMember
public JpaMapperModificationResetDomainMapperMember(com.broadleafcommerce.data.tracking.core.mapping.TrackableDomainMapperMemberSupport trackableDomainMapperMemberSupport, com.broadleafcommerce.data.tracking.core.mapping.ModelMapperDomainMapperMember modelMapperDomainMapperMember)
-
-
Method Details
-
getDataRoutePartition
- Specified by:
getDataRoutePartitionin interfacecom.broadleafcommerce.common.extension.data.DataRoutePartitionAware
-
modifyMap
public <D,P> D modifyMap(D repositoryDomain, P businessDomain, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, boolean allowNull) - Specified by:
modifyMapin interfacecom.broadleafcommerce.data.tracking.core.mapping.DomainMapper
-
deleteMap
public <D> D deleteMap(D repositoryDomain, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
deleteMapin interfacecom.broadleafcommerce.data.tracking.core.mapping.DomainMapper
-
detachEntityIfApplicable
protected <D> void detachEntityIfApplicable(D repositoryDomain, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @Nullable jakarta.persistence.EntityManager em) Remove the supplied entity instance from theEntityManagerinstance, if available.- Type Parameters:
D- The type of the entity- Parameters:
repositoryDomain- The entity instance to detachcontextInfo- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns.em- The singularEntityManagerinstance that is determined to be managing the entity instance.
-
getOrder
public int getOrder()- Specified by:
getOrderin interfacecom.broadleafcommerce.data.tracking.core.mapping.DomainMapperMember- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-