0

我有两个课程, ForfaitGenerique 和 Offre 。在 ForfaitGenerique 类中,“mappedBy”不识别“forfaitgenerique”;我收到此错误:

The bean encountered a non-application exception; nested exception is: 
javax.ejb.EJBTransactionRolledbackException: The transaction has been marked 
rollback only because the bean encountered a non-application exception :
org.apache.openjpa.persistence.ArgumentException : 
"isa.isola.entities.ForfaitGenerique.listeOffre" declared that it is mapped by 
"forfaitgenerique", but that is a not a field of the related type.

但是,如下所示,我的类是在 persistence.xml 中定义的;我无法理解问题出在哪里。

@Entity
public class ForfaitGenerique implements Serializable {
    @NotNull
    @OneToMany(cascade = {CascadeType.ALL},fetch = FetchType.LAZY,mappedBy = "forfaitgenerique")
    private List<Offre> listeOffre;

[...]

@Entity
public class Offre implements Serializable {

    @ManyToOne
    private ForfaitGenerique forfaitGenerique;

[...]

这是我的persistence.xml,有两个类ForfaitGenerique 和Offre。

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">

<persistence-unit name="tcf_persistence_unit" transaction-type="JTA">
    <jta-data-source>TCFDataSource</jta-data-source>

    <class>isa.isola.entities.Skieur</class>
    <class>isa.isola.entities.Forfait</class>
    <class>isa.isola.entities.ForfaitGenerique</class>
    <class>isa.isola.entities.PanneauStatique</class>
    <class>isa.isola.entities.PanneauDynamique</class>
    <class>isa.isola.entities.EtatsPistes</class>
    <class>isa.isola.entities.Piste</class>
    <class>isa.isola.entities.Statistique</class>
    <class>isa.isola.entities.Offre</class>

    <!--TODO:ajouter aussi SkieurPremium (?) et Commercant quand implémentées-->
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
    </properties>
</persistence-unit>

4

0 回答 0