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_MATCH
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionJpaMapperModificationResetDomainMapperMember
(com.broadleafcommerce.data.tracking.core.mapping.TrackableDomainMapperMemberSupport trackableDomainMapperMemberSupport, com.broadleafcommerce.data.tracking.core.mapping.ModelMapperDomainMapperMember modelMapperDomainMapperMember) -
Method Summary
Modifier and TypeMethodDescription<D> D
deleteMap
(D repositoryDomain, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected <D> void
detachEntityIfApplicable
(D repositoryDomain, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, javax.persistence.EntityManager em) Remove the supplied entity instance from theEntityManager
instance, if available.int
getOrder()
<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, wait
Methods inherited from interface com.broadleafcommerce.data.tracking.core.mapping.DomainMapper
getBusinessDomainType
Methods 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:
getDataRoutePartition
in 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:
modifyMap
in interfacecom.broadleafcommerce.data.tracking.core.mapping.DomainMapper
-
deleteMap
public <D> D deleteMap(D repositoryDomain, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
deleteMap
in interfacecom.broadleafcommerce.data.tracking.core.mapping.DomainMapper
-
detachEntityIfApplicable
protected <D> void detachEntityIfApplicable(D repositoryDomain, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @Nullable javax.persistence.EntityManager em) Remove the supplied entity instance from theEntityManager
instance, 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 singularEntityManager
instance that is determined to be managing the entity instance.
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfacecom.broadleafcommerce.data.tracking.core.mapping.DomainMapperMember
- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-