openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Annette Scherer" <annette.scher...@gmx.de>
Subject ManagedInterfaces
Date Fri, 06 Mar 2009 21:38:22 GMT
Hello,
 
we have several problems using OpenJPA with managed interfaces.
I try to explain:
 
preconditions
1. we use the model below. Each interface is implemented by a class with
postfix Impl
2. we continuously use ManagedInterfaces
3. we use OpenJPAEntityManager.createInstance(Class) to instantiate objects
 
 
problems
1. when reading a kategorie object with openJPAEm.find(Kategorie.class,
String name) we get an openjpa object like this, which differs from our
implementations.
 

 
When trying to call a method of one of our implementations (for example
fetchDomainAssociation on ParameterListeAtomarImpl, we get this exception:
[05.03.09 15:34:29:796 CET] 00000020 SystemErr R
java.lang.UnsupportedOperationException
[05.03.09 15:34:29:812 CET] 00000020 SystemErr R at
de.huk.vtp.selektionen.bo.ParameterListeAtomar$1841851848openjpaimpl.fetchDo
mainAssociation(Unknown Source)
 
How can we avoid this problem? It is a killer argument for using JPA in our
applications, for using interfaces is a corporation wide paradigma.
 
 
 
2. another problem is the use of inheritance. With annotations we used for
Parameter, ParameterAtomar for example, we receive this exeption:
[04.03.09 14:17:47:004 CET] 00000021 SystemOut O [04 Mär 2009 14:17:46]
DEBUG [LifecycleImpl.java:259 -- phase] - afterPhase(RESTORE_VIEW
1,com.icesoft.faces.context.BridgeFacesContext@60ae60ae) threw exception:
<openjpa-1.2.0-r422266:683325 fatal user error>
org.apache.openjpa.persistence.ArgumentException: Discriminator value
"ATOMAR" is used for two different classes in the same inheritance tree:
"interface de.huk.vtp.selektionen.bo.ParameterAtomar",
"de.huk.vtp.selektionen.bo.ParameterAtomar" Discriminator value "ATOMAR" is
used for two different classes in the same inheritance tree: "interface
de.huk.vtp.selektionen.bo.ParameterAtomar",
"de.huk.vtp.selektionen.bo.ParameterAtomar"

<openjpa-1.2.0-r422266:683325 fatal user error>
org.apache.openjpa.persistence.ArgumentException: Discriminator value
"ATOMAR" is used for two different classes in the same inheritance tree:
"interface de.huk.vtp.selektionen.bo.ParameterAtomar",
"de.huk.vtp.selektionen.bo.ParameterAtomar"

at
org.apache.openjpa.jdbc.meta.strats.ValueMapDiscriminatorStrategy.mapDiscrim
inatorValue(ValueMapDiscriminatorStrategy.java:116)

Thanks for you´r advice

Annette Scherer

 
 
 
 
 
 
 
extract of our model:
 
@Entity
@Table(name="TAKATEGORIE")
@ManagedInterface
public interface Kategorie extends Serializable{
     @Id
     @Column(name="NAME", length=50)
     public String getName();
     public void setName(String newName);
 
     @OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
     public java.util.List<Typ> getTypListe();
     public void setTypListe(java.util.List<Typ> newTypListe);
 
     public void addToTypListe(Typ o);
     public void removeFromTypListe(Typ o);
}
 
 
@Entity
@Table(name="TATYP")
@ManagedInterface
public interface Typ extends Serializable {
     @Id
     @Column(name="SELEKTIONSNUMMER", length=4)
     public String getSelectionID();
     public void setSelectionID(String newOperationId);
 
     @Column(name="NAME", length=60)
     public String getName();
     public void setName(String newName);
 
     @OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
     public java.util.List<Parameter> getParameterListe();
     public void setParameterListe(java.util.List<Parameter>
newParameterListe);
 
     public void addToParameterListe(Parameter o);
     public void removeFromParameterListe(Parameter o);
}
 
 
@Entity
@Table(name="TAPARAMETER")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="Typ", discriminatorType=DiscriminatorType.STRING)
@ManagedInterface
public interface Parameter extends Serializable{
     @Id
     @GeneratedValue(strategy=GenerationType.IDENTITY)
     public long getId();
     public void setId(long newId);
 
     @Column(name="KOMPONENTENTYP", length=50)
     public String getKomponentenTyp();
     public void setKomponentenTyp(String newKomponentenTyp);
}

 
@Entity(name="ATOMAR")
@ManagedInterface
public interface ParameterAtomar extends Parameter {

     @Column(name="NAME", length=50)
     public String getName();
     public void setName(String newName);
 
    @Column(name="BEZEICHNUNG", length=50)
     public String getBezeichnung();
     public void setBezeichnung(String bezeichnung);
}
 
@Entity
@ManagedInterface
public interface ParameterListeAtomar extends ParameterAtomar {
     public String getInhalt();
     public void setInhalt(String newInhalt);
 
     public void addToListenWerte(String o);
     public void removeFromListenWerte(String o);
 
     public DomainAssociation fetchDomainAssociation();
}
 
public class KategorieImpl implements Kategorie, Serializable {
    ..............
}
 
public class TypImpl implements Typ, Serializable {
    .............
}
 
public abstract class ParameterImpl implements Parameter, Serializable {
    ............
}
 
public abstract class ParameterAtomarImpl extends ParameterImpl implements
ParameterAtomar {
    ...........
}
 
 
public class ParameterListeAtomarImpl extends ParameterAtomarImpl implements
ParameterListeAtomar{
 private String inhalt;
 private List<String> listenWerte;
 
 public ParameterListeAtomarImpl() {
 }
 
 private String getInhalt() {
  return this.inhalt;
 } 
 
 private void setInhalt(String newInhalt) {
  this.inhalt = newInhalt;
  // do something else
 }

 private java.util.List getListenWerte() {
  return this.listenWerte;
 }
 
 private void setListenWerte(java.util.List newListenWerte) {
  this.listenWerte = newListenWerte;
  // do something else
 }
 
 public void addToListenWerte(String o) {
  this.getListenWerte().add(o);
  // do something else
 }
 
 public void removeFromListenWerte(String o) {
  this.getListenWerte().remove(o);
  // do something else }
 
  
 public DomainAssociation fetchDomainAssociation(){
  DomainAssociation da = //fetch a special object for further use
  return da;
 }
}

 
 
 

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