You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by John Nason <jo...@gmail.com> on 2007/07/27 20:22:25 UTC

Using interfaces with openJPA?

What is the best approach for using interfaces with persistable classes in
openJPA?
It seems like it is impossible to annotate interfaces for use with openJPA
persistence. For instance, I have 2 persistable classes that share the same
interface where the interface could contain the descriptors for both
implementations. You can not mark an interface as a @Entity. During
decoration a NPE is thrown.
Alternatively, I could describe my properties in an interface marked with a
@MappedSuperclass equivalent and then my implementors could inherit the
persistence information.
>From my experimentation interfaces do not seem to be supported in the
openJPA persistence paradigm. Is this is a current limitation with plans to
be addressed? Is this by design? If so, what is the reasoning behind this
decision? Interfaces are a big part of proper design in Java and I'm
suprised not to see them extensively used in the openJPA solution. If there
is valid reasoning why this should not be part of my design decision I'd
love to be informed.
Thanks for your time,
John Nason

Re: Using interfaces with openJPA?

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

I think that http://openjpa.apache.org/docs/latest/manual/manual.html#type
might answer your concerns. If that does not, can you outline your
model in a bit more detail?

-Patrick

On 7/27/07, John Nason <jo...@gmail.com> wrote:
> What is the best approach for using interfaces with persistable classes in
> openJPA?
> It seems like it is impossible to annotate interfaces for use with openJPA
> persistence. For instance, I have 2 persistable classes that share the same
> interface where the interface could contain the descriptors for both
> implementations. You can not mark an interface as a @Entity. During
> decoration a NPE is thrown.
> Alternatively, I could describe my properties in an interface marked with a
> @MappedSuperclass equivalent and then my implementors could inherit the
> persistence information.
> From my experimentation interfaces do not seem to be supported in the
> openJPA persistence paradigm. Is this is a current limitation with plans to
> be addressed? Is this by design? If so, what is the reasoning behind this
> decision? Interfaces are a big part of proper design in Java and I'm
> suprised not to see them extensively used in the openJPA solution. If there
> is valid reasoning why this should not be part of my design decision I'd
> love to be informed.
> Thanks for your time,
> John Nason
>


-- 
Patrick Linskey
202 669 5907