Brian Deterling created TAP5-2598:
-------------------------------------

             Summary: BeanDisplay cannot resolve Hibernate proxy
                 Key: TAP5-2598
                 URL: https://issues.apache.org/jira/browse/TAP5-2598
             Project: Tapestry 5
          Issue Type: Bug
          Components: plastic, tapestry-core, tapestry-hibernate
    Affects Versions: 5.4.3
            Reporter: Brian Deterling


When I attempt to use BeanDisplay on a Hibernate object, it fails when the 
object is lazily loaded. An example of the error is:

Unable to read class file for ....entities.Location_$$_jvst70_51.getCity()

The mapping is:
{code:java}
@ManyToOne(fetch=FetchType.LAZY)
private Location location;
{code}
 

Comparing 5.4 to an older version, the difference appears to be that 5.4 is 
using PlasticProxyFactory. This is getMemberLocation:
{code:java}
String className = member.getDeclaringClass().getName();
...
location = constructMemberLocation(member, methodName, memberTypeDesc, 
textDescriptionCreator.createObject());
...
ClassNode classNode = readClassNode(member.getDeclaringClass()); // This 
returns null
{code}
 

The older version uses ClassFactory:
{code:java}
Class declaringClass = method.getDeclaringClass();
Class effectiveClass = importClass(declaringClass);
...
CtClass ctClass = classSource.toCtClass(effectiveClass);
{code}
 The importClass line changes it from the proxy to the real class. That step 
appears to be missing in the newer version. 

 

Changing the new version to something like this, works around the issue, but 
I'm not confident enough in my knowledge of the code to know if it's correct:
{code:java}
Class declaringClass = member.getDeclaringClass();
if (org.hibernate.proxy.HibernateProxy.class.isAssignableFrom(declaringClass)) {
    declaringClass = declaringClass.getSuperclass();
}
ClassNode classNode = readClassNode(declaringClass);{code}
 

Am I missing a new configuration setting or a requirement that would avoid this 
issue?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to