Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] cache, eager loading and bi-directional relationships

I would tend to agree with your options, but do understand the easy of use
arguments for not having to worry about caching or LAZY relationships.

1 - The caches benefit depends on your application and environment.  I you
have a complex model, not having a cache could be a major performance issue,
especially if every relationship is EAGER.

2 - I would always use a bi-directional relationship for a
OneToMany/ManyToOne, usage of bi-directional OneToOne and ManyToMany would
depend on if they are required by the application.

3 - I would always recommend using LAZY, but do understand using EAGER makes
it a lot easier to serialize objects (also makes it easy to serialize way
too many objects without realizing it).  EclipseLink supports a LoadGroup
and FetchGroup to control what is instantiated for a query, and also
supports a CopyGroup to force instantiation and detach an object.


Cronemberger, Constantino wrote:
> 
> Hi,
> 
> I am doing some brainstorming with a few colleagues and some are saying
> that we:
> 
> 1 - should disable global cache because cache does not make a big
> difference and if database is in the same network then it should be fast
> enough
> 2 - better not use bi-directional relationships because it brings more
> complexity and at the end it is always possible to get the same results
> with a few more queries
> 3 - when it is necessary to serialize entities to send to the client (GWT
> or Swing apps for example) it is a good idea to configure all
> relationships as EAGER and remove some relationships to avoid to much data
> to be sent (when a relationship is marked as LAZY it will have a Set
> implementation that results in an empty set when a detached entity is
> serialized)
> 
> Personally I don't agree with any of those arguments and would appreciate
> if anybody can help me with some counter arguments.
> 
> My view is:
> 
> 1 - yes we can have problems with cache if we don't handle bidirectional
> relationships correctly or if we mix attached and detached entities in a
> relationship, I also think that cache really makes a difference and that
> it should be used unless there is a very good reason to do so, for example
> when a table can be changed by other systems
> 2 - bidirectional relationships allow us to create simpler queries and
> write less code and if they are coded correctly there should not be any
> problems
> 3 - we should use EAGER only when it makes sense to really load something
> every time we load a related entity, otherwise it is better to control
> what is going to be loaded with some query hints or just by calling
> relationship getters just before the entity gets serialized
> 
> Thanks a lot,
>     Constantino
> 
> 


-----
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 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/cache%2C-eager-loading-and-bi-directional-relationships-tp31428684p31441689.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top