FetchType « Fetch « JPA Q&A

1. @Basic(fetch = FetchType.LAZY) does not work?    stackoverflow.com

I use JPA (Hibernate) with Spring. When i want to lazy load a Stirng property i use this syntax:

@Basic(fetch = FetchType.LAZY)
public String getHtmlSummary() {
    return htmlSummary;
But when i look ...

2. Difference between FetchType LAZY and EAGER in Java persistence?    stackoverflow.com

Hi I am a newbie to Java persistence and Hibernate. What is the difference between FetchType LAZY and EAGER in Java persistence? Thanks

3. JPA 2 one-to-one fetch=FetchType.EAGER not working    stackoverflow.com

In my UserTbl entity, I have this

@OneToOne( cascade = CascadeType.REMOVE, mappedBy = "user", fetch=FetchType.EAGER )
private RetailPostUserTbl retailPostUser;

@OneToOne( cascade = CascadeType.REMOVE, mappedBy = "user", fetch=FetchType.EAGER )
private BackOfficeUserTbl backOfficeUser;
But both are ALWAYS null. A ...

4. FetchType.Eager is unable to fetch, FetchType.LAZY is also not working    stackoverflow.com

Hi I've made two entity classes named Designaton.java and Module.java. In Designation class there is a toMany relationship. I tried to Fetch data using FetchType.EAGEr as well as FetchType.LAZY also, ...

5. getResultList not honoring FetchType.LAZY    stackoverflow.com

I am using a complex native query to obtain multiple objects from the database. I am also using the following annotations in my Entity to obtain the results from that query:


6. Update a collection with fetchType = eager    forum.hibernate.org

Hi, I have two objects managed by hibernate with annotations Code: @Entity @Table(name = "person") public class Person { .......................... @OneToMany(fetch = FetchType.EAGER, targetEntity = Address.class, cascade = CascadeType.ALL) @JoinColumn(name = "idforeign_add") public Set

getAddresses() { return addresses; } ......................... } @Entity @Table(name ...

7. Question about FetchType.LAZY    forum.hibernate.org

Hi, When you are trying to get entityOne.getEntityTwo() , as you said hibernate will return proxy. The proxy holds a reference of session object which was jused to fetch entity two. Now if that session is closed before you call getEntityThree(), you will get LazyInitializationException. In case of Eager , real object and not proxy is returned and hence things will ...

8. FetchType.EAGER vs LazyCollectionOption.FALSE    forum.hibernate.org

Hi, When switiching to annotations it seems that there is a disctinction between using fetch=FetchType.EAGER vs LazyCollection(LazyCollectionOption.FALSE) - at least in one-to-many associations using a JoinColumn. Using LazyCollectionOption.FALSE results in usual performance/behavior similar to when using lazy="true" with xdoclet. Using FetchType.EAGER however results in larger SQL queries and slowdown. As far as hibernate is concerned, what exactly is the difference between ...

9. Why can't i have more then one FetchType.EAGER in an Entity?    forum.hibernate.org

I had started off my JEE5 experience using TopLink Essentials which for the most part was pretty painless. I noticed a few features that looked to be useful in the Hibernate JPA provider implementation such as @IndexColumn and I must say my painless experience has become very painful. There has been several things that had broke when I made the switchover ...

10. Hibernate FetchType.LAZY problem    forum.hibernate.org

Hi, I'm having a problem using FetchType.LAZY on hibernate 3.x where it does not call the database every time I want to use a OneToMany collection... Here is an example: class MyRoutine { ... @OneToMany private List steps; ... } When I update a step, and call getSteps() on MyRoutine it retrieves the data lazily as it is supposed to. However ...