Hi,
You can try OpenJPA-specific @Type annotation to designate that a relation
is declared as interface but will be given a persistence capable instance at
runtime. In your model, for example,
public class KategorieImpl implements Kategorie, Serializable {
private String name;
@ElementType(javax.persistence.Entity.class) // tells OpenJPA that
elements of TypListe will be instances of Typ interface
private List<Typ> typListe;
However, I think the support for interface is somewhat broken currently
(at least I cannot get to work the way it used to) -- I will do some
investigation when I get some time.
Hi,
How exactly should this be done.
1. Annotate interfaces (as @ManagedInterface) a n d additionally
implementing classes (as @Entity)
or
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?
greetings
Annette Scherer
Abteilung Informatik
-----Ursprüngliche Nachricht-----
Von: Pinaki Poddar [mailto:[email protected]]
Gesendet: Mittwoch, 11. März 2009 16:51
An: [email protected]
Betreff: Re: AW: AW: AW: ManagedInterfaces
Hi,
> 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:
http://n2.nabble.com/ManagedInterfaces-tp2438473p2462075.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
--
View this message in context:
http://n2.nabble.com/ManagedInterfaces-tp2438473p2469509.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.