Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 16:06 Go to next message
Roger Suen is currently offline Roger SuenFriend
Messages: 4
Registered: May 2010
Junior Member
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 17:52 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.


James : Wiki : Book : Blog : Twitter
Re: PluralAttribute.getJavaType returns element type instead of collection type [message #540067 is a reply to message #536970] Mon, 14 June 2010 18:25 Go to previous messageGo to next message
Gordon Yorke is currently offline Gordon YorkeFriend
Messages: 78
Registered: July 2009
Member
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 21:20 Go to previous message
Michael OBrien is currently offline Michael OBrienFriend
Messages: 34
Registered: July 2009
Member
>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 Apr 19 08:12:00 GMT 2024

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

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

Back to the top