openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scherer, Annette" <Annette.Sche...@huk-coburg.de>
Subject AW: AW: AW: ManagedInterfaces
Date Wed, 11 Mar 2009 14:46:46 GMT
Here is my persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
        version="1.0">
        <persistence-unit name="Selektionen_DB">
                <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
                <jta-data-source>java:comp/jdbc/selektionendb</jta-data-source>
                <class>de.huk.vtp.selektionen.bo.Typ</class>
                <class>de.huk.vtp.selektionen.bo.Kategorie</class>
                <class>de.huk.vtp.selektionen.bo.Parameter</class>
                <class>de.huk.vtp.selektionen.bo.ParameterAtomar</class>
                <class>de.huk.vtp.selektionen.bo.ParameterTextAtomar</class
                <class>de.huk.vtp.selektionen.bo.ParameterListeAtomar</class>
                <properties>
                        <property name="openjpa.TransactionMode" value="managed"/>
                        <property name="openjpa.ConnectionFactoryMode" value="managed"/>
                        <property name="openjpa.jdbc.DBDictionary" value="db2"/>
                            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
                        <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO,
Tool=INFO, SQL=TRACE"/>
                </properties>
        </persistence-unit>
</persistence>

We put the annotations only on Interfaces. (See examples below). Therefore we only inserted
Interfaces into persistence.xml
When inserting interface and implementing class into persistenc.xml, for example ParameterDatumAtomar
and .ParameterDatumAtomarImpl we receive following Exception.


[10.03.09 09:39:59:703 CET] 0000001e ExceptionUtil E   CNTR0020E: EJB hat eine unerwartete
(nicht deklarierte) Ausnahme beim Aufruf der Methode "testJPASelektion" für Bean "BeanId(Selektionen_JPA_EAR#Selektionen_JPA_EJB.jar#SelektionenJPATest,
null)" ausgelöst. Ausnahmedaten: <openjpa-1.2.0-r422266:683325 fatal user error> org.apache.openjpa.persistence.ArgumentException:
Type "class de.huk.vtp.selektionen.bo.ParameterDatumAtomarImpl" does not have persistence
metadata.
        at org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:682)
        at org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:748)
        at org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:646)
        at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:153)
        at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119)
        at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189)
        at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
        at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
        at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
        at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
        at de.huk.vtp.selektionen.bo.prototyp.InitNeu.getOpenEm(InitNeu.java:618)
        at de.huk.vtp.selektionen.bo.prototyp.InitNeu.initErgebnisSpaltenMap(InitNeu.java:461)
        at de.huk.vtp.selektionen.jpa.ejb.SelektionenJPATestBean.testJPASelektion(SelektionenJPATestBean.java:119)
        at de.huk.vtp.selektionen.jpa.ejb.EJSRemoteStatelessSelektionenJPATest_b1c5ee64.testJPASelektion(EJSRemoteStatelessSelektionenJPATest_b1c5ee64.java:27)
        at de.huk.vtp.selektionen.jpa.ejb._SelektionenJPATest_Stub.testJPASelektion(_SelektionenJPATest_Stub.java:264)
        at de.huk.vtp.selektionen.jpa.web.SelektionenJPATestServlet.doWork(SelektionenJPATestServlet.java:46)
        at de.huk.vtp.selektionen.jpa.web.SelektionenJPATestServlet.doGet(SelektionenJPATestServlet.java:34)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
        at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
        at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
        at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
        at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
        at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
        at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
        at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
        at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
        at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
        at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
        at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
        at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
        at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

[10.03.09 09:39:59:781 CET] 0000001e ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl initialize
FFDC0009I: FFDC hat die Datenstromdatei C:\Programme\IBM\SDP70_1\runtimes\base_v61\profiles\AppSrv02\logs\ffdc\server1_43804380_09.03.10_09.39.59_0.txt
für das Ereignis geöffnet.
[10.03.09 09:39:59:828 CET] 0000001e ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream
FFDC0010I: FFDC hat die Datenstromdatei C:\Programme\IBM\SDP70_1\runtimes\base_v61\profiles\AppSrv02\logs\ffdc\server1_43804380_09.03.10_09.39.59_0.txt
für das Ereignis geschlossen.
[10.03.09 09:39:59:859 CET] 0000001e SystemOut     O RemoteException occurred in server thread;
nested exception is:
        java.rmi.RemoteException: ; nested exception is:
        <openjpa-1.2.0-r422266:683325 fatal user error> org.apache.openjpa.persistence.ArgumentException:
Type "class de.huk.vtp.selektionen.bo.ParameterDatumAtomarImpl" does not have persistence
metadata.



Annette Scherer
Abteilung Informatik



-----Ursprüngliche Nachricht-----
Von: Rick Curtis [mailto:curtisr7@gmail.com]
Gesendet: Montag, 9. März 2009 20:47
An: users@openjpa.apache.org
Betreff: Re: AW: AW: ManagedInterfaces


Annette -
Have you confirmed that de.huk.vtp.selektionen.bo.ParameterListeAtomarImpl
has been enhanced?

-Rick

Scherer, Annette wrote:
>
> I call org.apache.openjpa.enhance.PCEnhancer
>
> Annette
>
>
> Annette Scherer
> Abteilung Informatik
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Rick Curtis [mailto:curtisr7@gmail.com]
> Gesendet: Montag, 9. März 2009 14:24
> An: users@openjpa.apache.org
> Betreff: Re: AW: ManagedInterfaces
>
>
> Annette -
> How are you enhancing your Entities?
>
> -Rick
>
>
> Scherer, Annette wrote:
>>
>> Hi,
>>
>> unfortunately this approach does not lead to desired behaviour. When
>> instantiating our implemented class with  ParameterListeAtomar pc = new
>> ParameterListeAtomarImpl(...) as suggested, we receive another error:
>>
>> Exception in thread "main" <openjpa-1.2.0-r422266:683325 nonfatal user
>> error> org.apache.openjpa.persistence.ArgumentException: Attempt to cast
>> instance "de.huk.vtp.selektionen.bo.ParameterListeAtomarImpl@10e35d5" to
>> PersistenceCapable failed.  Ensure that it has been enhanced.
>>
>>
>> This corresponds to Apache OpenJPA User's Gide
>> (http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/manual.html#ref_guide_pc_interfaces)
>>
>> What else can we do?
>>
>>
>> Greetings
>> Annette Scherer
>>
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Pinaki Poddar [mailto:ppoddar@apache.org]
>> Gesendet: Sonntag, 8. März 2009 19:50
>> An: users@openjpa.apache.org
>> Betreff: Re: ManagedInterfaces
>>
>>
>> Hi,
>>   > 3. we use OpenJPAEntityManager.createInstance(Class) to instantiate
>> objects
>>
>>    This method will create a class *dynamically* which implements the
>> given
>> interface.
>> As the stacktrace shows, it has created a class named
>> 'de.huk.vtp.selektionen.bo.ParameterListeAtomar$1841851848openjpaimpl'.
>>     But this dynamically generated class does not know what do when some
>> calls its fetchDomainAssociation() method on it and simply will throw
>> exception. It only knows how to behave for its bean-style get/set
>> methods.
>>
>>    So, for this use case where you not only use ManagedInterface but also
>> have implemented these interfaces, you should instantiate your
>> implemented
>> class directly i.e.
>>    ParameterListeAtomar pc = new ParameterListeAtomarImpl(...);
>>
>>   You can continue using the interface for find() or query such as
>>    ParameterListeAtomar pc = em.find(ParameterListeAtomar.class, someId);
>>   This should return you an instance of ParameterListeAtomarImpl which
>> has
>> the correct implementation of fetchDomainAssociation().
>>
>>
>>
>>
>>
>> Annette Scherer wrote:
>>>
>>> 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;
>>>  }
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/ManagedInterfaces-tp2438473p2445629.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>>
>>
>
> --
> View this message in context:
> http://n2.nabble.com/ManagedInterfaces-tp2438473p2448900.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>
>

--
View this message in context: http://n2.nabble.com/ManagedInterfaces-tp2438473p2451233.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message