I have a JPA entity as follow:
@Entity @DynamicUpdate @TypeDef(name = "json_binary", typeClass = JsonBinaryType::class) public class Workflow { private Long id; private String name; @Type(type = "json_binary") @Column(columnDefinition = "jsonb") private List<AccessModel> users; } public class AccessModle { private String name; private Int permission; } And the repository:
@Repository public interface WorkflowRepository extends JpaRepository<Workflow, Long> {} Now when I just want to find a workflow(repository.findById(1)), The hibernate log is as follow:
Hibernate: select workflow0_.id as id1_12_0_, workflow0_.name as name2_12_0_, workflow0_.users as users3_12_0_ where workflow0_.id=? Hibernate: update workflow set users=? where id=? I didn't modify users, But Hibernate set it. How can I prevent automatically update entity?
Update:
@Service @Transactional public class WorkflowServiceImpl { @Autowired private WorkflowRepository repository; public Workflow find(Long id) { return repository.findById(id); } }
repository.findById(1)?AccessModleso that jpa can verify fields not updatedworkflowService. findand what they are doing with the result and does that method have@Transactionaltoo?