简单的OneToMany级联(全部)不起作用; mappedBy,org.apache.openjpa.persistence.ArgumentException

时间:2016-04-30 08:20:25

标签: java ejb persistence.xml mappedby

我有两个课程,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>

0 个答案:

没有答案
相关问题