AFAIK JPA has no way to known which fields were modified, it knows only that the entity instance must be updated.
The only way I see now is refreshing the instance, compare values, set those which changed then apply the changes in the recently retrieved instance.
Also check your application for changes in the entity because one thing is for sure: flush only updates database if some of the setXXXX methods were called even if with the same value.
Read up on the @Version annotation for Hibernate. You may be able to artifically increase the version from the C application. Big question marks here so worth checking out. This would only allow your app to generate an OptimisticLockException (or something like that).
AFAIK you can't partially update an entity out-of-the-box but you could store the entity in another object, then refresh the entity from the database (entityManager.refresh()) then compare the values and only update what you want. Messy & fussy but would work. I do similar to generate version history for entity changes (eg.
User X did this)