Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » managing in-memory references held on the owning side
managing in-memory references held on the owning side [message #542104] Wed, 23 June 2010 21:10 Go to next message
Fericit Bostan is currently offline Fericit BostanFriend
Messages: 68
Registered: June 2010
Member
I see in JPA 2.0 spec that there is the statement:

Quote:
It is the developer's responsibility to keep the in-memory references held on the owning side and those held on the inverse side consistent with each other when they change.


I remember this from the 1.0 spec as well, where I had to manage the relationships. So I'm guessing that this still holds true as it is printed in the 2.0 spec.

I was just wondering if there was an easier way, that EclipseLink may have implemented so I don't need to manage these exclusively, specifically, during a remove operation. Currently, when I remove an entity from the EntityManager

EntityManager.remove(entity)


I am removing the associations in the @PreRemove method I have defined on each of my Entity beans that require this management.

    @PreRemove
    protected void preRemove() {
		getParentObject().getSomeCollection().remove(this);  	
    }


Is this the cleanest way to handle the management of those relationships or can I improve on this?

Thanks for the help...


Re: managing in-memory references held on the owning side [message #542152 is a reply to message #542104] Thu, 24 June 2010 05:41 Go to previous message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
> Is this the cleanest way to handle the management of those relationships
> or can I improve on this?

Personally I handle the relationships in the corresponding setters and getters (adders and removers for the collections). So a remove immediately removes it from in memory collections as well, not at storage time.
Previous Topic:Static Weaving through Eclipse Plug-in
Next Topic:Inherited OneToOne relationship not hydrated properly
Goto Forum:
  


Current Time: Thu Apr 25 13:16:55 GMT 2024

Powered by FUDForum. Page generated in 0.02997 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top