diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java index e27a071e7e8d..ab1a59ad5dea 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java @@ -615,6 +615,13 @@ else if ( !CollectionUtils.isEmpty( params.getTrackedEntityTypes() ) ) } } + if ( params.isSynchronizationQuery() ) + { + trackedEntity + .append( whereAnd.whereAnd() ) + .append( " TEI.lastupdated >= TEI.lastSynchronized " ); + } + if ( !params.isIncludeDeleted() ) { trackedEntity