// Some comments here
Map<String, Object> hints = new HashMap<>();
hints.put(QueryHints.HINT_READONLY, true);
Pupil pupil = em.find(Pupil.class, pupilId, hints);//bug
pupil.setAge(newAge);
does not turn off dirty checking.
To check it download sample project https://github.com/stsypanov/spring-data-examples and run BaseJpaRepositoryImplFindOneReadOnlyTest.testFindOneReadOnlyTrue_useEntityManager_expectValueNotUpdated