Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » PluralAttribute.getJavaType returns element type instead of collection type
PluralAttribute.getJavaType returns element type instead of collection type [message #536547] Fri, 28 May 2010 12:06 Go to next message
Eclipse UserFriend
In eclipselink implementation of JPA 2.0 metamodel API, PluralAttribute.getJavaType() returns the element type instead of the collection type. Here's the snippet:

    
org.eclipse.persistence.internal.jpa.metamodel.PluralAttributeImpl.java:

/**
     *  Return the Java type of the represented attribute.
     *  @return Java type
     */
    @Override
    public Class<C> getJavaType() {
        return (Class<C>)elementType.getJavaType();
    }


Is this what the specification means, or just a bug? I have checked the source code of hibernate, they choose to return the collection type from the method. I think this make sence because for a PluralAttribute, we have getElementType method there.

I'm working on eclipselink-2.0.2.v20100323-r6872.

Thanks for any helps

Roger

Re: PluralAttribute.getJavaType returns element type instead of collection type [message #536970 is a reply to message #536547] Mon, 31 May 2010 13:52 Go to previous messageGo to next message
Eclipse UserFriend
Looking into it, the getJavaType() seems correct. To get the type of the Collection you use, getCollectionType() which returns one of List, Set, Collection, Map. getElementType() returns the same type, just as a Type instead of a Class.

Looks like Hibernate has a bug.
Re: PluralAttribute.getJavaType returns element type instead of collection type [message #540067 is a reply to message #536970] Mon, 14 June 2010 14:25 Go to previous messageGo to next message
Eclipse UserFriend
The implementation of getJavaType() in EclipseLink is not correct for PluralAttribute. getBindableType should return the type of the referenced Entity. getJavaType() returns the type of the attribute, which for PluralAttribute is the type of the collection.

A bug (314906) has been filed for this issue.
--Gordon
Re: PluralAttribute.getJavaType returns element type instead of collection type [message #540375 is a reply to message #536547] Tue, 15 June 2010 17:20 Go to previous message
Eclipse UserFriend
>See SVN Rev# 7618 for Trunk EclipseLink 2.2
http://fisheye2.atlassian.com/changelog/eclipselink/?cs=7618
>EclipseLink 2.1.1 will be packported when the stream opens shortly
Code Reviewed by: Guy Pelletier
JPA 2.0 specification adherence reviewed by: Gordon Yorke, James Sutherland and Mike Keith


http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/meta model_api#DI_104:_20100614:_314906:_PluralAttribute.getJavaT ype_returns_elementType_instead_of_Collection_Type
https://bugs.eclipse.org/bugs/attachment.cgi?id=171844&a ction=diff
http://bugs.eclipse.org/314906

thank you to Roger Suen for finding and reporting on this spec compliance issue.
/michael
Previous Topic:Auditing for Oracle with EclipseLink JPA
Next Topic:Recommended way to store XML data with EL
Goto Forum:
  


Current Time: Fri Jul 18 13:53:06 EDT 2025

Powered by FUDForum. Page generated in 0.31120 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top