|
|
|
[
Permlink
| « Hide
]
Joerg Schaible - 31/Aug/07 01:37 AM
Sorry, but I don't see a difference. Why should the first condition break Hibernate proxies ?
No further response, reopen if you want to answer my question.
Closed after no further comment has been given.
Actually CGLIBEnhancedConverter does not work for lazy loaded collections. Actually when adding callbacks Hibernate (I am using Hibernate 3.2.5) two callback types are registered - the 2nd callback type is NoOp.class which is basically No Operation. (See the CGLIBLazyInitilaizer class of hibernate source for more details). In the CGLIBEnhancedConverter of xstream callbacks are retrieved in the following way -
Callback[] callbacks = hasFactory ? ((Factory)source).getCallbacks() : getCallbacks(source); In the callbacks array the 2nd callback is always null for Hibernate lazy loaded classes. But as the callbacks.length is checked for >1, it throws an exception. I have changed the condition from - if (Arrays.asList(callbacks).size() > 1) { to if (callbacks.length > 1 && (callbacks[1] !=null && callbacks.length != 2)) { In this case this worked perfectly. I would appreciate comments on this. I have tried to find out the CGLIB proxy policy of Hibernate (as I am not a Hibernate Pro, and actually there is almost no documentation or javadoc about Hibernate's use of CGLIB, I failed). Later I posted to hibernate-dev mailing list to find out the detail (http://lists.jboss.org/pipermail/hibernate-dev/2008-May/003085.html
Do you have plan to work on this in the next release of Xstream (If you are busy, I would be happy to submit a patch)? This will really help in this field as I have tried JDK xmlEncoder/decoder, Commons Betwixt, Castor, Simple framework, but failed to serialize Java beans to XML with simple converter or persistentDelegates. Only Xstream with the above change is able to correctly handle Hibernate lazy loaded collections (i.e. CGLIB enhanced classes) properly. Can't say. I'll have to analyze this first. The converter is for CGLIB enhanced proxies in general, not only for ones that are created by Hibernate.
This issue biting me right now. I've got a Hibernate cglib proxy with two callbacks. 0 is a org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer and 1 is null.
Why is a null callback ever a problem? Don't we just need to exclude multiple instantiated callbacks? Callback[] callbacks = hasFactory ? ((Factory)source).getCallbacks() : getCallbacks(source); ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedClass(callback.getClass()), callback.getClass()); and private Callback extractUniqueCallback(Callback[] callbacks) { Any updates on this issue? my investigation brought me to the same conclusion, there are two
callbacks registered but one of them is a null, can't we simply ignore nulls? Can't NoOp.class also be considered ignorable? Any news on when we can expect this to be resolved? Thanks, Kaz- |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||