Hi Matt,

I don't know that I can offer much help on this. The problem is that the Producer binding code is correctly casting the passed in object to an instance of Producer, while what Hibernate is supplying is apparently an instance of org.prx.user.UserImpl$$EnhancerByCGLIB$$4c56d3d - which is *not* an instance of Producer. I suspect the problem lies in your Hibernate mapping for the hierarchy of classes Producer-UserImpl-Member. Does Hibernate know that it needs to create an instance of Producer, rather than the base class, in the place where you're expecting it? My guess is that it does not, so it's just creating a UserImpl instance and returning that.

To verify this, have you tried this code you suggested (and if so, what is the type of the object it returns)?

if (proxy instanceof HibernateProxy){
return ((HibernateProxy)proxy).getHibernateLazyInitializer().getImplementation();
}

In any case, a possible work around would be to have your JiBX AbstractPieceImpl mapping use the UserImpl mapping directly with the "creator" name. That way JiBX wouldn't care whether the actual instances are UserImpl or Producer.

 - Dennis

Dennis M. Sosnoski
SOA, Web Services, and XML
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-296-6194 - Wellington, NZ +64-4-298-6117



Matt MacDonald wrote:
Hi Dennis,

I really appreciate the help. Right now we are exposing a read only view of our object model via some hand crafted XML output - I can see the value in using this and it works wonderfully when not connected to hibernate.

I've attached the JiBX compiled classes for UserImpl and Producer. About the proxy... I know this is Hibernate specific but I was thinking that somewhere in the JiBX binding code that when returning back Objects either from direct calls to the fields or via the get/set methods that the object is then inspected to see if it is a Hibernate proxy... if it is it calls ((HibernateProxy)proxy).getHibernateLazyInitializer ().getImplementation(); to get the actual class. Maybe I could specify in the bind mapping that the object that is being returned is of a proxy type and then when JiBX generates it's bytecode enhancements it could call the getImplementation() method.

-matt





-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to