Dynamic proxies to auto-save models
- by atomman
I'm trying to make some auto-magic happen in java using proxies to track objects and saving them when a set* method is called. I started of using java's built in Proxy, and everything works just fine, but from what I can understand I need a interface for every model, which is something that I'm trying to avoid.
This is where CGLIB comes in, it allows me to create proxies of my models without the use of interfaces. BUT, how can I now retrieve the original object, the one I am trying to save?
The optimal solution to be would be something like the EntityManager interface used by hibernate, where you keep your original object, but it is still tracked.