Dynamic proxies to auto-save models

Posted by atomman on Stack Overflow See other posts from Stack Overflow or by atomman
Published on 2012-10-02T08:21:19Z Indexed on 2012/10/02 9:37 UTC
Read the original article Hit count: 163

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate