Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Betr.: Re: [eclipselink-users] Strange persistence layer behaviour


Well, the mappins have indeed been specified on both sides of the relationship...the LetterOfCreditGoederenOmsRegel entity contains the following:

    @ManyToOne(cascade=CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinColumns({
        @JoinColumn(name = "LIVLG", referencedColumnName = "LIVLG", insertable = false, updatable = false),
        @JoinColumn(name = "IKONR", referencedColumnName = "IKONR", insertable = false, updatable = false),
        @JoinColumn(name = "IKRNR", referencedColumnName = "IKRNR", insertable = false, updatable = false) })
    private LetterOfCreditGoederenOms goederenOms;

    public LetterOfCreditGoederenOms getGoederenOms() {
        return goederenOms;
    }

So, still puzzled by this..

Regards,

Willem Kunkels
Java Developer

Koopman International BV
Distelweg 88
1031 HH  Amsterdam
The Netherlands
Tel.: +31 20 494 7 893
www.koopmanint.com



James Sutherland <jamesssss@xxxxxxxxx>

26-08-2009 16:33

Antwoord a.u.b. aan
EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>

Aan
eclipselink-users@xxxxxxxxxxx
Cc
Onderwerp
Re: [eclipselink-users] Strange persistence layer behaviour






This occurs because EclipseLink caches by default, and you seem to have
corrupted your objects in your cache.  Most likely when you created these
objects, you set the 1-1 but did not add to the 1-m, you must always set
both sides of the relationship in JPA.  Even without caching, you would
still be corrupting your EntityManager.

You should ensure you update both sides of the relationship.  You could also
disable caching using the persistence.xml property,
"eclipselink.cache.shared.default"="false".



Clogs wrote:
>
> Hi all,
>
> I have come across something that I do not quite understand, maybe someone
> can shed a light...
>
> Here is the situation:
>
> The entity LetterOfCreditGoederenOms contains lines wich can be retrieved
> through the following mapping:
>
>     @OneToMany(cascade=CascadeType.REFRESH, mappedBy = "goederenOms",
> fetch = FetchType.LAZY)
>     private Collection<LetterOfCreditGoederenOmsRegel> regels;
>
>     public Collection<LetterOfCreditGoederenOmsRegel> getRegels() {
>         return regels;
>     }
>
> I have a bean that contains logic to compare two objects and determine
> changes between the two. In one case I check whether I need to remove
> something from the database. If so, I do the following:
>
>                     omschrijving = getEm().find(LetterOfCreditGoederenOms.
> class,
>                             new
> LetterOfCreditGoederenOmsPK(omschrijving.getVolgnummerInkooporder(),
>                                     omschrijving.getInkoopOrderNr(),
> omschrijving.getInkoopOrderRegelNummer()));
>                     getRemovedObjects().add(omschrijving);
>                     getRemovedObjects().addAll(omschrijving.getRegels());  
>  
>
> What I would expect (now that the LetterOfCreditGoederenOms object
> 'omschrijving' is managed) is that the call to getRegels() will get me the
> lines associated with the omschrijving object. It does not do this.
> What I need to do to get this working is adding the following just after
> the find:
>
>                         // A little note:
>                         // You would expect that the regels can be
> retrieved by
>                         // calling the getRegels() method. For some reason
> unknown,
>                         // the persistence layer does not do this. The
> only way
>                         // to get the regels is a refresh of the object we
> just
>                         // found: cascading refresh then does get the
> regels...
>                         // weird...
>                         getEm().refresh(omschrijving);
>
> Anyone's got an answer to this enigma?
>
> Cheers,
>
> Willem Kunkels
> Java Developer
>
> Koopman International BV
> Distelweg 88
> 1031 HH  Amsterdam
> The Netherlands
> Tel.: +31 20 494 7 893
> www.koopmanint.com
>
>


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Strange-persistence-layer-behaviour-tp25149315p25151391.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top