|Re: [eclipselink-users] Fetching with eclipselink|
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
Back to the top