openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scherer, Annette" <>
Subject AW: AW: AW: AW: ManagedInterfaces
Date Thu, 12 Mar 2009 07:12:46 GMT


How exactly should this be done.
1. Annotate interfaces   (as @ManagedInterface)   a n d   additionally implementing classes
(as @Entity)
2. Annotate only classes and not use ManagedInterfaces at all

To my experience the latter one would implicate that we cannot type class attributes to interfaces.
For example we now use

public class KategorieImpl implements Kategorie, Serializable {
        private String name;
        private List<Typ> typListe;

We would have to change List<Typ>  into List<TypImpl>.  Is this correct??

public class KategorieImpl implements Kategorie, Serializable {
        private String name;
        private List<TypImpl> typListe;

This would limit flexibility to change implementation behind an interface. So, we depend on
using interfaces.

In case of 2.
Is there another altenative to use JPA with the definitions above?


Annette Scherer
Abteilung Informatik

-----Ursprüngliche Nachricht-----
Von: Pinaki Poddar []
Gesendet: Mittwoch, 11. März 2009 16:51
Betreff: Re: AW: AW: AW: ManagedInterfaces

>  We put the annotations only on Interfaces. (See examples below).
> Therefore we only inserted Interfaces > into persistence.xml.
  1. As you require to invoke non-bean methods (e.g. fetchDomainData()) of
your implementation class, then you need to annotate them as @Entity.
  2. You need to specify these implementation classes in persistence.xml
<class> clause
  3. You need to instantiate these classes directly rather than calling
OpenJPAEntityManager.newInstance(InterfaceX.class), because otherwise
OpenJPA will not know that actually you want an instance of your
implementation class InterfaceXImpl and *not* a dynamically generated class
that implements InterfaceX.

> When inserting interface and implementing class into persistenc.xml, for
> example ParameterDatumAtomar
> and .ParameterDatumAtomarImpl we receive following Exception.
This exception is raised because ParameterDatumAtomarImpl  is not annotated
as @Entity.

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message