Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Generics and ORM and inferring field types

EclipseLink 2.5.2.

I have a supertype declared like this:

public abstract class Substance<I extends Serializable, V extends Comparable<V> & Serializable> implements Serializable {

  private I id;

  private V version;

  public I getId() {
    return this.id;
  }

  public V getVersion() {
    return this.version;
  }

  // etc.

}

Then I have a concrete subtype that instantiates it:

public class Something extends Substance<Integer, Integer> {

}

I am using XML descriptors exclusively.

In my mapping file, I list Something as an entity in a normal fashion, declaring that it has an id attribute named id.

EclipseLink complains at deployment time; the gist seems to be that it thinks that the field named id is of type String.

Debugging into the EclipseLink 2.5.2 source code, I can see that EclipseLink thinks that the id field in the Substance class is of type Serializable as you'd expect with type erasure in play.

Is there some other way that EclipseLink might be able to infer that for my Something entity the field will hold an Integer?  Is this use of generics not handled by JPA?

Best,
Laird

--
http://about.me/lairdnelson

Back to the top