Entity « Fetch « JPA Q&A





1. Avoiding multiple joins on hql with abstract entities    stackoverflow.com

I'm having trouble using hql with the following mapping (classes are between brackets):

[Note] @OneToMany [Item]; [SubItem1] extends [Item]; [SubItem2] extends [Item]; ...

2. How to retrieve the limited collection of related entities?    stackoverflow.com

Suppose, we have an entity User, which has many comments. It is possible to do so:

List<Comment> = user.getComments();
But this will load all the comments of the user. How should we retrieve just first ...

3. Fetch Non-Existent Entities with Join    forum.hibernate.org

Thanks in advance for your help. I have, what I consider to be a complicated relationship between entities and I am not sure the best way to implement. I've tried numerous ways with no luck. As you can see below, I have a Test entity which represents a test that can be taken by a student, it contains a list of ...

4. Join Fetch returns same entity multiple times    forum.hibernate.org

Hello, I've got two tables Community and Zipcode with a one to many relationsship (one community may have multiple zipcodes). I'd like to pre-fetch the zipcodes in order to access them after the session is closed. If I modify the mapping file by setting lazy="false" then it works! But if I specifiy a Join Fetch explicitely in the Criteria or HQL, ...

5. Criteria api - retrieve only root entity    forum.hibernate.org

According to Java Persistence with Hibernate, in HQL if you do: "from Item i join i.bids b" it will return all combinations of of bids and items. If you do : "select i from Item i join i.bids b", it will return just the items. I'm using the criteria API and I'm only interested in the root entities. By default, it's ...