Created
January 24, 2020 22:35
-
-
Save dfreudenberger/2187b71e2492347139960188b13113b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
class UpdateTotalPriceInterceptor extends EmptyInterceptor | |
{ | |
@Override | |
public void preFlush(Iterator entities) | |
{ | |
while (entities.hasNext()) { | |
updatePriceIfOrder(entities.next()); | |
} | |
super.preFlush(entities); | |
} | |
private void updatePriceIfOrder(Object entity) | |
{ | |
if (entity instanceof Order) { | |
((Order) entity).updateTotalPrice(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment