foreign key « Fetch « JPA Q&A





1. How can I prevent Hibernate fetching joined entities when I access only the foreign key id?    stackoverflow.com

I have a Hibernate entity Parent that is joined to another: Child. In the database I have a column parent.child_id that has a foreign key constraint on child.id. Assuming I'm lazily ...

2. EAGER fetching on foreign keys unavoidable during inserts?    forum.hibernate.org

Hi all, I have got an (@Embeddable) entity (Address) with a FK to a fully flagged reference entity (Country). Everything is working ok, however I can see that before each insert into Address, a select on Country occurs as the following log demonstrates: Hibernate: /* get current state uk.co.jemos.persistence.domain.reference.Country */ select country_.COUNTRY_ID from COUNTRY country_ where country_.COUNTRY_ID=? Hibernate: /* insert uk.co.jemos.persistence.domain.user.User ...

3. need clarifications about retrieve by foreign_key    forum.hibernate.org

I got the following example from old disscussion forum about how to retrieve by foreign key. I also check 9.7 of doc. But I am still not clear about how this gonna work. "FROM foo IN CLASS eg.Foo WHERE foo.bar.id = 666 (The second query is efficient. No table join is required.)" Here foo and bar has on-to-many relationship, in order ...

4. many-to-one relationship unable to retrieve foreign key HB3    forum.hibernate.org

Author Message dawuad Post subject: many-to-one relationship unable to retrieve foreign key HB3 Posted: Mon May 09, 2005 5:09 pm Regular Joined: Wed Sep 29, 2004 11:34 am Posts: 62 Location: Houston, TX I am having trouble with many-to-one relationship. I am unable to retrieve the foreign key and get a LazyInitializationException error. I have set the many-to-one property ...