Hi!
To me, it makes sense to use Transfer Objects,
* How do you deal with versioning?

If you directly use the hibernate object and use lock() to reassociate it you can use hibernates versioning check to see if another user already changed this object too and can tell the user its change is no longer valid.

You might have to do this yourself if you detach your object into a transfer object, dont you?


* How do you know which fields in your transfer object have changed?

You can use aspectj or simply booleans, but this also sound a little bit of duplicate programming with respect to hibernate which already handles it.


I am fully convinced it is best to reload hibernate objects and utilize the second level cache where possible, but when it comes to "data change forms" (user loads a record/edit it/save it some times later) its better to use a "page scoped" hibernate object. So in fact it would be great to have a method to reattach those objects before any other action will be executed.

What I would try is to give my hibernate object a marker interface "PersistentObject" and create a converter for it. So x:saveState use this converter and on recreation of this object it should be possible to reattach it. If it is a stale object a custom error page can be displayed.


---
Mario

Reply via email to