openjpa-dev mailing list archives

Hi devs,
I'd like to start work on adding generics support into OpenJPA.
Specifically, I'd like to allow the following:
@MappedSuperclass
public class Identifiable<T> {
private T id;
@Id
public T getId() { return id; }
private void setId(T i) { id = i; }
}
@Entity
public class Concrete extends Identifiable<Integer> {
...
}
@Entity
public class CompoundConcrete extends Identifiable<CompoundConcrete.PK> {
@Embeddable
protected static class PK {
...
}
}
Currently, for example, the code fails when trying to get the metadata for
Concrete because it believes that Id is of type java.lang.Object, which "is
not a persistent type". This is because the getReturnType() method in
java.reflection.Method returns java.lang.Object if the return type is a
generic; additional API calls must be used.
>From my searches I've not found a precise bug that matches this exact
problem, but I've found several other bugs related to generics that have not
been assigned to anyone yet. Hopefully, I'll be able to fix all the
generics-related bugs.
With this in mind, is there any potential problems I should be aware of
before attempting to hack at the code? Anything you guys can foresee that
makes generics impossible? From what I've read, nothing in the JPA spec
refers to generics directly at all; but since Generics is a compile-time
transformation, I don't see why it shouldn't work with JPA/OpenJPA.
Shall I open a bug with this exact problem also, before I get going?
Thanks,
atanamir
--
View this message in context: http://openjpa.208410.n2.nabble.com/Generics-Support-tp5049201p5049201.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.