检测Java对象是否已被修改? [英] Detect if a Java-object has been modified?

查看:233
本文介绍了检测Java对象是否已被修改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到我有一个标准的Java bean:即它包含 String List 的成员, HashMap 等等。

Consider that I’ve got a standard Java bean: i.e. it contains members that are String, List, HashMap, etc.

我的问题是:检测此类对象的实例是否有最简单的方法是什么?从先前/原始状态被修改?

My question is: what’s the easiest way to detect if an instance of such an object has been modified from say a previous/original state?

我想知道这个的原因是我决定是否应该更新数据库中的对象,如果:(i)没有变化已经完成了,或者(ii)进行了更改,但随后又进行了更改。

The reason I want to know this is so I determine whether I should update the object in the DB, or not, in the case where either: (i) no changes were made, or (ii) changes were made but then reversed.

我一直在考虑hashCode或byte []的比较,但似乎没有工作。有什么想法吗?

I’ve been thinking about comparison of hashCode, or byte[], but doesn’t seem to work. Any ideas?

推荐答案

是的,它可以完成,已经完成了......它被称为 hibernate 。只需使用它,不要重新发明轮子

Yes, it can be done, and it has been done... it's called hibernate. Just use that and don't "reinvent the wheel"

这篇关于检测Java对象是否已被修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆