openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From it-media.k...@daimler.com
Subject @OneToMany/@ManyToOne Weirdness (List contains non-matching elements)
Date Mon, 19 Jan 2009 10:20:13 GMT
Hello Everybody,

I'm having some weird issues with a simple OneToMany/ManyToOne Situation. 
The data model is as follows:

@Entity
@Table(name = "REFERENZCODES")
public class ReferenzCode
{ 
    @Id
    @Column(name = "RFC_CODE")
    private String code;
 
    @Column(name = "RFC_BEZEICHNUNG")
    private String bezeichnung;
 
    @Column(name = "RFC_PFLEGE_KZ")
    private String pflegeKennzeichen;
 
    @Column(name = "RFC_USER_ID")
    private String userId;
 
    @Column(name = "RFC_DATUM")
    private Date aenderungsDatum;
 
    @Version
    @Column(name = "RFC_VERSION")
    private long version; 
 
    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST, 
mappedBy="parent")
    private List<ReferenzWert> referenzWerte;
 
    @Entity
    @Table(name = "REFERENZWERTE")
    public static class ReferenzWert
    {
        @Id
        @Column(name = "RFW_CODE")
        private String code;
 
        @Column(name = "RFW_RFC_CODE")
        private String referenzCode; 
 
        @Column(name = "RFW_SUBRFC_CODE")
        private String subCode;
 
        @Column(name = "RFW_TEXT")
        private String text;
 
        @Column(name = "RFW_WERT")
        private long wert;
 
        @Column(name = "RFW_ALTERNATIV_TEXT")
        private String alternativText;
 
        @Column(name = "RFW_ALTERNATIV_WERT")
        private long alternativWert;
 
        @Column(name = "RFW_DATUM")
        private Date aenderungsDatum;
 
        @Column(name = "RFW_USER_ID")
        private String userId;
 
        @Version
        @Column(name = "RFW_VERSION")
        private long version;
 
        @ManyToOne
        @JoinColumn(name="RFW_RFC_CODE")
        private ReferenzCode parent;
          }
}

While the @ManyToOne is completely correct, the @OneToMany contains for a 
RFC_CODE/RFW_RFC_CODE = "SPARTE" elements in the List that do NOT belong
to this leading to the following situation

        ReferenCode (SPARTE)
                -> referenWerte
                        0 -> ReferenzWert (5) with parent ReferenzCode 
(SPARTE)
                        1 -> ReferenzWert (8) with parent ReferenzCode 
(<somethingElse>)

I do not really understand what happends here. All ReferenzWerte of 
ReferenzCode SPARTE are present, BUT there are some additional ones that 
do not belong
here.

Any help with this issue would be appreciated. I'm using Websphere 6.1 
(FeaturePack EJB3 with openJPA 1.0.3). If I do a manual query for all 
ReferenzWerte to
a certain ReferenzCode via NamedQuery, everything works as expected.

Thanks in advance,

Heiko 

--
Dr.-Ing. Heiko Kopp / Fa. GFI - iT media Consult GmbH
c/o Mercedes-Benz Bank
HPC 032 - ITF/FS-DPS
70469 Stuttgart

Tel.: 0711 2574-6144
Fax: 0711 2574-96144
E-Mail: it-media.kopp@daimler.com

If you are not the intended addressee, please inform us immediately that you have received
this e-mail in error, and delete it. We thank you for your cooperation.  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message