0

I have two classes, ForfaitGenerique and Offre . In the class ForfaitGenerique, the "mappedBy" doesn't recognize "forfaitgenerique" ; I am getting this error :

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.

However, a shown below, my classes are defined in the persistence.xml ; I cannot understand where is the problem.

@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;

[...]

And here is my persistence.xml, the two classes ForfaitGenerique and Offre are there .

<?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>

Bénédicte Lagouge
  • 482
  • 2
  • 9
  • 24
  • Case sensitive? `forfaitgenerique` and `forfaitGenerique` – Geinmachi Apr 30 '16 at 08:25
  • Read the error message carefully. It complains about a non-existing field named `forfaitgenerique`. Do you have such a field? I don't see any. I see a field named `forfaitGenerique`, though. Java is case-sensitive. Voting to close as typo. – JB Nizet Apr 30 '16 at 08:25
  • Ok.x) Yup.Thanks a lot and I agree, this dumb post should be closed... – Bénédicte Lagouge Apr 30 '16 at 08:29

0 Answers0