Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Static Metamodel gencode error ... for wildcard Collection field (CanonicalModelProcessor generate wrong source code for ListAttribut<X, Z> if Z is like "? extends E")
Static Metamodel gencode error ... for wildcard Collection field [message #1027274] Tue, 26 March 2013 19:52 Go to next message
Claude Bernard Diesse is currently offline Claude Bernard DiesseFriend
Messages: 9
Registered: December 2011
Junior Member
Hi All,
I wonder if i am missing something, but I used to declare in the past, some Entity's collection fields using wildcard parameter type. But actually, the EclipseLink metamodel processor generates wrong code from that fields declaration

example:

Original entity classes :

package model.base;

@Entity @Table(name = "MOMAP") 
public class MetaEntity  extends BaseEntity<Long> {
  private static final long serialVersionUID = 1L;

  @ManyToOne(optional = false)  @JoinColumn(table = "MOMETA", name = "TID", referencedColumnName = "ID")  private EntityType entType;
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "sourceTranslation")  protected List<? extends EntityTranslation> translations;

}



The generated static metamodel code look like this :
package model.base;

import ? extends model.base.EntityTranslation;
import com.kasor.model.base.EntityType;
import javax.annotation.Generated;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;

@Generated(value="EclipseLink-2.4.1.v20121003-rNA", date="2013-03-26T19:41:30")
@StaticMetamodel(MetaEntity.class)
public class MetaEntity_ extends BaseEntity_ {
    public static volatile SingularAttribute<MetaEntity, EntityType> entType;
    public static volatile ListAttribute<MetaEntity, EntityTranslation> translations;
}



As it is showed in the import line of the generated code, the processor don't correctly recognize the wildcard parameter in the List field declaration.

My Questions :
1. Does JPA specs allow/limit use of wildcard/bounded parameters for collection fields ?
2. Is this a bug or limitation of the eclipseLink static metamodel generator/processor ?

I searched in JPA 2 specifications and found no hint restricting the use of wilcard or bounded type parameters.

When I change the definition to :
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "sourceTranslation")  protected List<EntityTranslation> translations;

The processor correctly generate the static metamodel files.

I also dont' have any warning from a regular javac source compilation of my entity classes ...

May someone share his thought about this and/or help for a workaround ?

regards.

[Updated on: Thu, 28 March 2013 10:24]

Report message to a moderator

Re: Static Metamodel gencode error ... for wildcard Collection field [message #1030654 is a reply to message #1027274] Sun, 31 March 2013 14:30 Go to previous messageGo to next message
Claude Bernard Diesse is currently offline Claude Bernard DiesseFriend
Messages: 9
Registered: December 2011
Junior Member
No response since for my question about use of wildcard in JPA 2 collection parameter type ?

I want to know if i am allowed to declare an entity field (@OneToMany relation) using wildcard as follow :

  @OneToMany(cascade = CascadeType.ALL, mappedBy = "sourceTranslation")  protected List<? extends EntityTranslation> translations;


or if this is forbidden and restricted to this :
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "sourceTranslation")  protected List<EntityTranslation> translations;


If there is no such limitation, can we say that EclipseLink static metamodel generator have a bug and file a bug in bugzilla ?

Thanks for any help.

[Updated on: Tue, 02 April 2013 09:48]

Report message to a moderator

Re: Static Metamodel gencode error ... for wildcard Collection field [message #1037112 is a reply to message #1027274] Tue, 09 April 2013 07:24 Go to previous messageGo to next message
Claude Bernard Diesse is currently offline Claude Bernard DiesseFriend
Messages: 9
Registered: December 2011
Junior Member
As no one can answer if this is a EclipseLink bug or not, I will go further and file a bug in bugzilla.

For my concern, I really need to use that Java generic capability, to do ORM and efficiently filter data for specialized entities.

thanks for your help.
Re: Static Metamodel gencode error ... for wildcard Collection field [message #1043328 is a reply to message #1037112] Wed, 17 April 2013 15:08 Go to previous message
Guy Pelletier is currently offline Guy PelletierFriend
Messages: 19
Registered: July 2009
Junior Member
Could be a bug, please enter one. The spec does state it should be a parameterized type but would have to look into it more of what exactly is allowed. You can get around it for the time being by adding a targetEntity=EntityTranslation.class in the to the @OneToMany mapping.
Previous Topic:Using Left Join without metamodel classes
Next Topic:[Moxy] Problem on unmarshalling using Document instead of InputStream
Goto Forum:
  


Current Time: Tue Oct 15 01:24:08 GMT 2024

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

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

Back to the top