openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <>
Subject Re: Generics Support
Date Fri, 14 May 2010 12:50:14 GMT
Hi Atanamir,
I'm not a Generics expert, but I don't see any roadblocks with what you are
attempting.  You're basically trying to use Generics to create a template
Class for creating Entity types, correct?  Based on your notes, it sounds
like the tricky part will to know when to use the additional reflection
methods to get the root types.  Or, maybe there's some "signal" to indicate
that the root type has been found.

The best way to start is to open a (feature) JIRA.  Add your notes and
findings to this JIRA.  This way, you can start a conversation and
discussion on the topic and keep it all in one place.  When you think you
have something to share, then you could post a patch to the JIRA and ask for
reviews/comments.  Hopefully, you'll find a "committer partner" through this
process and they can help guide you the process of getting your changes into
the code base.

I'm assuming you are looking at the trunk release for this enhancement?

Good luck and Thanks for contributing!

On Thu, May 13, 2010 at 9:16 PM, atanamir <> wrote:

> 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:
> Sent from the OpenJPA Developers mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message