I'm trying to use Jibx (beta3c-1.0) with hibernate (v3) and run into
problems when I want to use hibernate laziness.
The following happens:

- I have an Order.java class and its associated .hbm.xml
- I design the Jibx mapping for the order class and associated objects.

<mapping name="order" class="Order">

  <value name="number" field="orderNbr" usage="optional"/>
  <value name="creationDate" field="creationDate" usage="optional"/>

  <structure name="paymentInfo" field="paymentInfo">
    <value name="creditCardNbr" field="creditCardNbr"/>
  </structure>

</mapping>


When I try to marshall an Order object ( instantiated from the database
), I get the following error:
"Unable to access binding information for class
Order$$EnhancerByCGLIB$$4c139633 Make sure the binding has been
compiled"

The error makes sense because the concrete class I'm getting is really
the subclass generated by hibernate to handle laziness. Of course I
never defined a binding for this class, but would it be possible to have
Jibx use the mapping for the declared class ?

So I turned of lazyness for my Order class ( I still have it for
PaymentInfo ), and now have the following:

java.lang.NullPointerException
        at
org.jibx.runtime.impl.UTF8Escaper.writeAttribute(UTF8Escaper.java:67)
        at
org.jibx.runtime.impl.GenericXMLWriter.writeAttributeText(GenericXMLWrit
er.java:200)
        at
org.jibx.runtime.impl.XMLWriterBase.addAttribute(XMLWriterBase.java:338)
        at
org.jibx.runtime.impl.MarshallingContext.attribute(MarshallingContext.ja
va:488)
        at PaymentInfo.JiBX_marshalAttr_2_0(PaymentInfo.java)

Wich also makes sense, the creditCardNbr attribute in my
PaymentInfo$$EnhancerByCGLIB$$... object is still null because it hasn't
been accessed yet.
For this I have a workaround, as I can set the get-method to the
standard extractor ( here getCreditCardNbr()) and have hibernate resolve
the field value.
Maybe it would be nice to have Jibx use the extractor by default ?

Anyway, using lazyness is a requirement in my case, I guess most
hibernate users needs this feature too. I really hope there is a way
Jibx can handle the enhanced class generated by hibernate.
Thanks a lot for your help,

Arnaud Lenfant


-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to