Hi,
I'm using Hibernate 4.3.10.FINAL, with the latest evaluation version of ZK 8.0 (http://zkoss.org/). I want to use the MVVM pattern and ZK's form binding.
In the case you're not familiar with it, it works like that: I have a form in a ZK window that is represented by a ViewModel. The ViewModel is just a Java bean that has some fields representing the data in my form. These fields are beans managed by Hibernate. So, they can be proxies.
ZK's form binding is a system that creates a middle object, so when I do a modification in my form, it's not propagated to the ViewModel right away. It is stored in the middle object which is a proxy of the ViewModel (more info here: http://books.zkoss.org/zk-mvvm-book/8.0/data_binding/form_binding.html).
Therefore, my problem is that ZK tries to transform into a proxy an object that already contains proxies. Please note that ZK's "proxification" seems to be recursive: the ViewModel becomes a proxy, all its fields become proxies, all their fields become proxies, and so on. I get this exception:
Code:
java.lang.RuntimeException: duplicate method: setHandler in com.company.package.MyClass_$$_jvst8dc_10_$$_jvst8dc_1d
javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:515)
javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:492)
javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:428)
javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:400)
org.zkoss.bind.proxy.ProxyHelper.createProxyIfAny(ProxyHelper.java:88)
org.zkoss.bind.proxy.BeanProxyHandler.invoke(BeanProxyHandler.java:163)
com.company.package.MyOtherClass_$$_jvst8dc_1b.getMyClass(MyOtherClass_$$_jvst8dc_1b.java)
com.company.package.MyOtherClass.equals(MyOtherClass.java:38)
java.util.ArrayList.indexOf(ArrayList.java:298)
org.zkoss.zul.ListModelList.indexOf(ListModelList.java:247)
org.zkoss.zul.ListModelList.fireSelectionEvent(ListModelList.java:458)
org.zkoss.zul.AbstractListModel.addToSelection(AbstractListModel.java:125)
org.zkoss.bind.converter.sys.ListboxSelectedItemConverter.coerceToUi(ListboxSelectedItemConverter.java:48)
org.zkoss.bind.impl.LoadPropertyBindingImpl.load(LoadPropertyBindingImpl.java:74)
org.zkoss.bind.impl.PropertyBindingHandler.doLoadBinding(PropertyBindingHandler.java:133)
org.zkoss.bind.impl.PropertyBindingHandler.doLoad(PropertyBindingHandler.java:334)
org.zkoss.bind.impl.BinderImpl.loadComponentProperties0(BinderImpl.java:2307)
org.zkoss.bind.impl.BinderImpl.loadComponent0(BinderImpl.java:2276)
org.zkoss.bind.impl.BinderImpl.loadComponent0(BinderImpl.java:2281)
org.zkoss.bind.impl.BinderImpl.loadComponent0(BinderImpl.java:2281)
org.zkoss.bind.impl.BinderImpl.loadComponent0(BinderImpl.java:2281)
org.zkoss.bind.impl.BinderImpl.loadComponent(BinderImpl.java:2215)
org.zkoss.bind.BindComposer$BinderKeeper$Loader.load(BindComposer.java:564)
org.zkoss.bind.BindComposer$BinderKeeper.loadComponentForAllBinders(BindComposer.java:540)
org.zkoss.bind.BindComposer.doAfterCompose(BindComposer.java:188)
org.zkoss.zk.ui.impl.UiEngineImpl.doAfterCompose(UiEngineImpl.java:588)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:924)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:870)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:745)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:709)
org.zkoss.zk.ui.impl.UiEngineImpl.createComponents(UiEngineImpl.java:1124)
org.zkoss.zk.ui.impl.AbstractExecution.createComponents0(AbstractExecution.java:283)
org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:271)
org.zkoss.zul.Include.afterCompose(Include.java:486)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:922)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:870)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:745)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:709)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:916)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:870)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:745)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:709)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:916)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:870)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:745)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:709)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:916)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:870)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:745)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:814)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:767)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:709)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:452)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:358)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:217)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:136)
javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
What I already tried but it doesn't work:
- Not using ZK's form binding: when collections are lazy-loaded, some modifications are flushed to the database, even if I didn't click on "Save"
- Not lazy-loading any collection: that's not really an option
- Setting CGlib as Hibernate's bytecode provider to avoid the fact that both Hibernate and ZK use Javassist: it doesn't work anymore, it has been deprecated a long time ago
If that can help you, I posted a question on ZK's forum: http://forum.zkoss.org/question/98594/form-binding-middle-object-in-zk-80-what-if-my-viewmodel-properties-are-proxies/ but for now I couldn't get any help.
Thanks in advance for any idea!