hql « Fetch « JPA Q&A





1. hql query to retrieve top n from each group    stackoverflow.com

i want to achieve the following in HQL - select top n from table1 where table1.id IN (some select sub query) i have found the setMaxResult(n) method, but it can only retrieve ...

2. Hibernate HQL and fetching with grouping    stackoverflow.com

We have a hibernate pojo Reporting/ReportingID that has several properties that contain counts, dates, actions, and devices. The device property mapped to a hibernate pojo called Device (note: I want ...

3. HQL with multiple fetch joins    forum.hibernate.org

Hi, I'm trying to read data with Hibernate 3.6.8. I have this kind of query SELECT a FROM A as a left join fetch a.b as b left join fetch a.c as c WHERE a.id = :id AND b.name = :name AND c.name = :name There are 3 tables: A, B, C. "A" is the master table joined with "B" and ...

4. HQL with multiple fetch joins    forum.hibernate.org

Hi, I'm trying to read data with Hibernate 3.6.8. I have this kind of query SELECT a FROM A as a left join fetch a.b as b left join fetch a.c as c WHERE a.id = :id AND b.name = :name AND c.name = :name There are 3 tables: A, B, C. "A" is the master table joined with "B" and ...

5. Using Fetch In HQL    forum.hibernate.org

I looked around thinking this is answered somewhere but didn't find anything...... I'm using Hibernate 2.0.2. I'm creating the following HQL: Code: List ads = session.createQuery("select distinct ad from com.itsolut.entity.tracker.Ad as ad " + ...

6. hql many-to-many fetching    forum.hibernate.org

...

7. HQL to retrieve the Top 10 most sold products    forum.hibernate.org

I've two table - Sales and Products. I want to retrieve the Top 10 most sold products. I try to do this with this HQL: String qry = "select l, sum( Vendas.quantidade ) " + "from Livro l " + "group by l.codigo " + "order by sum( Vendas.quantidade )"; The sales table has a relationship mapped to product: ----- Sales.hbm.xml ...

8. Need for experience... HQL query "join fetch" vs M    forum.hibernate.org

Hibernate version: 2.1.7 Hi, My question might get me down in flames, I know I'm new to Hibernate, and hence would like to hear about more experienced users about fetch strategies... I have the following (among others) schema: "Catalog" * <-> * "Product" -> * "Option" When the user displays a catalog page, I only show available products, depending on the ...

9. Fetch in HQL query    forum.hibernate.org

Hi all, I'm trying to optimize a query with FETCH joins in order to avoid many selects. I have the following query: select uepc from UserEnterpriseProfileCourse as uepc JOIN FETCH uepc.uepcPK.uep as uep JOIN FETCH uep.user as user where uep.company.id = :idCompany and uepc.uepcPK.course.id = :idCourse My classes are in the following way: class UserEnterpriseProfileCourse { @EmbeddedId UserEnterpriseProfileCoursePK uepcPK; /* ... ...





10. How to avoid fetching unnecessary data via HQL    forum.hibernate.org

Hi all, I've been using Hibernate for the past two and a half years with great results, but there's something that's been bugging me for a long time now: why I can't get Hibernate to avoid fetching unnecessary data via HQL. Let's say I have the following tables: Country: ID (PK), Description Maker: ID (PK), Description, Country ID (FK) Disk: ID ...