Cloning EntityProxies

90 views
Skip to first unread message

Rogelio Flores

unread,
Mar 20, 2012, 4:12:20 PM3/20/12
to google-we...@googlegroups.com
I have started to use RequestFactory (RF) recently (long-time RPC user).

There's something I haven't found how to do apart from manually copying data; I want to clone an EntityProxy. In fact, one that contains a 1:n mapping (contains a List of other EntityProxies). Not sure this last part matters, but in other words, from a given myAEntityProxy1 that is already persisted in the DB, does RF have anything that allows me to simply clone it so that I end up with a new myAEntityProxy2 that has the exact same data as myAEntityProxy1, and after a few changes or no changes at all, when persisted, gets saved into the DB without overriding myAEntityProxy1? (I want new record(s) to be created).



gwtomni gwtomni

unread,
Apr 12, 2012, 11:57:27 AM4/12/12
to google-we...@googlegroups.com
try with this:


                AutoBean<T> oldBean = AutoBeanUtils.getAutoBean(oldProxy);
                AutoBean<T> newBean = AutoBeanUtils.getAutoBean(newProxy);
                AutoBeanCodex.decodeInto(AutoBeanCodex.encode(oldBean), newBean);
                newProxy = newBean.as();
                context.edit(newProxy);

El Mentecato Mayor

unread,
Aug 28, 2012, 9:48:33 PM8/28/12
to google-we...@googlegroups.com
This works! Thanks.
(just wanted to state that for the record).
Reply all
Reply to author
Forward
0 new messages