Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Fetching with eclipselink

Hi Gordon,

Thanks for the tip. But does this result in two different queries?
One for loading the Product (maybe from cache) and one for loading the Category(maybe from cache)?

And how can I let Eclipselink do the work, without using my named query?

I have a loadProductById, that loads the product, but not its Category. How can Eclipselink load the category from cache?
And how do I know if an object is in the cache?

Leon





Gordon Yorke wrote:
Hello Leon,
See email from Tom Ware, but I would like to add that if you have not disabled caching and in your application you would expect the Category object to be in the cache, you will get much better performance not joining this relationship but allowing EclipseLink to retrieve the related object from the cache without a database query at all. For those times when you know that Category will not be in the cache you can use the named query.
--Gordon

Leon Derks wrote:
Hello

I have an object Product with a @ManyToOne relation to a Category Object.

Default the fetch type of this relation is EAGER (Category is loaded, when Product is loaded). But when I load a Product by Id, I see there is a second select that loads the Category object.

This is not what I want. Why doesn't eclipselink translates thisautomatically in one single query?

I temporary solved this by defining a named query: select p from Product p inner join fetch p.category where p.id = :productId.

Now a product and its category are loaded in one select statement.

Is there a way to let eclipselink automatically load the objects in one select or do I always have to use a named query for this?

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





Back to the top