Hi,

Congrats for coming up with such a wonderful tool ! :-)

In a particular parent-child use case, my object graph looks like this :

[ParentImpl] <implements> [ParentInterface]
[ChildInterface] <extends> [ParentInterface]
[ChildImpl] <extends> [ParentImpl], <implements> [ChildInterface]

While mapping them as hibernate entities, I had specified "proxy=[ParentImpl]" for the parent class and "proxy=[ChildInterface]" for the child one. However, this resulted in Hibernate cribbing "org.hibernate.MappingException: proxy must be either an interface, or the class itself: [ChildImpl]". This looked strange since the proxy specified for child was indeed an interface (as mentioned above).

>From the stack trace, I was able to get the piece of code that does this validation. Here is it, from org.hibernate.tuple.PojoTuplizer.buildProxyFactory(...),with my comments added :

    [...]
Class mappedClass = persistentClass.getMappedClass();
        Class proxyInterface = persistentClass.getProxyInterface();

        if ( proxyInterface!=null && !mappedClass.equals( proxyInterface ) ) {
            if ( !proxyInterface.isInterface() ) {
                throw new MappingException(
                        "proxy must be either an interface, or the class itself: " +
                        getEntityName()
                );
            }
            proxyInterfaces.add( proxyInterface );
        }

        if ( mappedClass.isInterface() ) {
            proxyInterfaces.add( mappedClass );
        }

        Iterator iter = persistentClass.getSubclassIterator();
        while ( iter.hasNext() ) {
            Subclass subclass = ( Subclass ) iter.next();
            Class subclassProxy = subclass.getProxyInterface();
            Class subclassClass = subclass.getMappedClass();
            if ( subclassProxy!=null && !subclassClass.equals( subclassProxy ) ) { // *** [Vikas S] : This correctly checks subclassProxy ***
                if ( !proxyInterface.isInterface() ) { // *** [Vikas S] : But why proxyInterface ??? Shouldn't this be subclassProxy ??? ***
                    throw new MappingException(
                            "proxy must be either an interface, or the class itself: " +
                            subclass.getEntityName()
                    );
                }
                proxyInterfaces.add( subclassProxy );
            }
        }
      [...]

As mentioned in my inline comment, while iterating through the sub-class mappings it is validating proxyInterface (proxy defined for parent) instead of subclassProxy. Is this intended ?? Please advise.

Thx & Rgds,
Vikas.

-- 
"Quidquid latine dictum sit, altum sonatur"
Whatever is said in Latin, sounds profound.





-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to