Convert « Query « JPA Q&A

1. having trouble converting a query to hql

I'm pretty new to HQL (well, nhibernate in general) and am currently building a simple app to learn more about it. I've run into problems trying to express the following sql as ...

2. Converting Hibernate linq query to HQL

I understand that a IQueryable cannot be serialized. That means that queries can not be serialized, sent to a webservice, deserialized, queried and then sent back. I was wondering if it is ...

3. Converting a HQL-query which includes elements() to Criteria API

I'm having trouble converting the following HQL-query to Criteria API and I was wondering if I could get some help from you guys

SELECT child FROM Foo AS child 
WHERE child IN ...

4. Help converting SQL query to JPQL

I have a SQL query that I need to translate over into JPQL, and I'm beginning to wonder if this is one of the cases where I'll just have to use ...

5. How to convert MySQL query into HQL query?

I am new to HQL. This is a mysql Query. I need to convert it into HQL query. How to do that any suggestions please?


6. convert HQL query to criteria api

I'm wondering if is possible to convert this HQL query into a criteria api query.

select s1 
from Student

7. convert subquery to a join in jpql

I have two classes ClassA and ClassB. Many ClassB's can have association with a single ClassA, hence a many-to-one relationship from ClassB to ClassA. Relationship is like:

ClassA {

8. Is it possible to convert JPQL query result with multiple Object types into JSON format automatically?

I'm using JPA Toplink, JAX-RS, NetBean6.9 So far I successfully convert JPQL query result which is List with one object type into JSON. Following works fine, it generates JSON by the time it ...

9. need help converting HQL query to LINQ to Objects

Here is my HQL query: select p, pp, pp.Mrn, pp.Name from PatientProfile pp left join pp.Patient p where pp.Name.FamilyName like firefly% Any help would be greatly appreciated. Thanks!

10. How to convert HQL with Group By to QueryOver?

I have a HQL query:

select max(l.Num) from SomeTable l group by l.Type, l.Iteration
How can I translate/convert it to QueryOver? Following one:
var grouped = session.QueryOver<SomeTable>()
    .SelectList(l => l

11. Convert SQL into HQL where clause

HI all, This should be easy, but my app throws constant error, and i am new to hibernate. I am trying to have simple HQL query in my web app using hibernate SQL: ...

12. help converting hql query to queryover (or help improving the query)

I have written a hql query that aggregates some data using the results of a common queryover query, and I'm wondering if it's possible to do something similar entirely within queryover-land. ...

13. convert sql to hql

I am performing this via sql but i want to do this in hql, select statement in from ( select count(*)...) not works in hql, any sugestion and optimization would ...

14. How to convert MySQL date/time query to Hibernate query

I have a MySQL query which needs to be converted to Hibernate query format. MySQL query :

select jobs.execSchdID, 
jobs.nextRunDate, jobs.employee.empID, jobs.project.projectCode from 
AutoExecSchedule jobs where jobs.nextRunDate > current_timestamp() and 
to_date(to_char(jobs.nextRunDate, 'DD-MON-YY') = ...

15. Converting Native distinct on sql query to hql

I want to convert following native sql query to hql query. I gone through hibernate docs they given examples on queries with distinct objects/fields but no where given about "distinct on" ...

16. Convert named query to criteria query

My named query looks like this, thanks to here.

query="select c 
      from Usercat as uc 
      inner join ...

17. Converting HQL query to Criteria query

18. converting sql query to hql

Hi, I'd like to convert the following query to hql... Anyone knows? It's pretty complicated! Thanks, Steve SELECT DISTINCT a.* , NVL(b.COL1, 0) AS WORKING , NVL(c.COL2, 0) AS RECRUITED , NVL(d.COL3, 0) AS FIRED FROM PM_CATEGORY a LEFT OUTER JOIN (SELECT CATEGORY_ID, COUNT(*) OVER (PARTITION BY CATEGORY_ID, TRE_NODE_ID3) AS COL1 FROM EM_EMPL_FILE WHERE TRE_NODE_ID3 = 1 ) b ON a.ID ...

19. Converting existing sql query to hibernate native sql query???

Hi, I am currently trying to convert one of our existing module to hibernate (For POC). In this process, i require all our existing sql queries to be converted to hibernate based queries. Could any one please help me (as im new to hibernate) by giving example to convert the following existing sql query to hibernate native query? (Please note that: ...

20. Please help me to convert this SQL to hibernate query

select a.msisdn,sum(b.amount) 'amount' from account a inner join accrued_Transaction b on a.msisdn = b.msisdn where a.account_group = 300 and a.opt_in_date is null and b.year <= 2010 AND b.quarter <= 2 AND (b.opted_in is null OR b.opted_in = 1) GROUP BY b.msisdn, a.msisdn HQL seems to be not accepting ON class Thanks in advance

21. How to Convert HQL to SQL Query

22. Convert SQL query to HQL query

23. how to convert round(sum(c11*count)/sum(count),2) c11 in HQL

Hi, please let me know how to convert the below SQL query in HQL. SELECT date1, ID, c1,c2,c3,round(sum(c11*count)/sum(count),2) c11,SUM(count) count FROM xxx WHERE date1 >= ? AND date1 <= ? AND ID = ? GROUP BY date1,c1,c2,c3 Here count is a column in the table. when i converted into HQL i got the below error. Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: expecting ...

24. Please convert this SQL query to hibernate

25. Need help converting SQL with join & where clause to HQL

I need help converting the following SQL query into HQL syntax using Criteria. Select distinct vh.vehicle_id from vehicle vh left join odometer_months om on vh.vehicle_id=om.vehicle_id where vh.vehicle_id not in (select vehicle_id from odometer_months where month=7 and year =2010). We have the following two tables Vehcile - Stores all vehicle information with vehicle_id as primary key Odometer_Months - Stores odometer reading for ...

26. I get "?" in actual query in DB in convert(datetime where cl

Hi I have a native sql query with count(*) in which I have datetime criteria converted using MS SQL function Convert(datetime..) while in debug I see the query properly formatted in "Query object" but as soon as I used list() function I get exception saying "[SQLServer JDBC Driver][SQLServer]Conversion failed when converting datetime from character string.". So If I check my Jboss ...

27. convert hibernate query results into arraylist

Hi to all, i have a search page which retrieves data corresponding to the employee name which i entered. i have to display arraylist contents on jsp page by iterating them. here i need to convert hibernate query results into arraylist. how can i do this? i have a confusion on this conversion. please guide me.

28. Having troubles converting SQL query to HQL

Regular Joined: Tue Jun 08, 2004 8:24 am Posts: 57 I'm having problems porting an SQL query over to HQL. I'm using Hibernate 2.1, with Postgresql 7.4.2. I have the following data objects that I'm generating the database from: /* * @hibernate.class table="bsFileInformation" */ public class FileInformation implements Serializable { /* * * generator-class="native" * column="id" * unsaved-value="-1" * type="long" ...

29. Please give a hint to convert this sql query into hql

Hibernate version: 2.1 Database: MySQL 4.0.17-nt My Problem: I want to get all projects from a specific user when he is the user of a project or when he is in the project team of a project: The SQL Query works but i have problems to write the hql counterpart select distinct p.* from User as u, PROJECT_TEAM as t, PROJECT ...

30. Need to Convert SQL Query to HQL (join ON)...

I need to convert this SQL Query to a Hibernate QL... I have Problems withe the Keyword "ON"... HQL doesn't take it. Is there a way to work arround the "ON"? And can I get a Resultlist of the three Entities (Table1 , Table2 and Table3) at once.. Perhaps like an Array Object? //... q = em.createQuery("FROM Table1 t, Table2 a, ...

31. Can't convert outer join HQL query to Criteria

32. Converting HQL Query to a Criteria Query

Need help with Hibernate? Read this first: ... AskForHelp Hibernate version: 3.x Mapping documents:

34. how to convert criteria query to HQL

35. How to convert following optimize MYSQL Query in HQL

As i am new to the hibernate and have less knowledge about it ... So if anyone here know how to write the following query in HQL ... The MYSQL query :- select from Pages p use index (seq_number_one) where p.scene_id = :sceneid and p.seq_Number > 0 order by p.seq_Number ; My Current working HQL Query is :- select ...

36. how to convert sql queries to hql queries?

37. Converting HQL to Criteria Query

39. converting SQL query to Hibernate

hi, i'm tring to work on an assignment where we have a SQL query that involves about four tables. as we are moving to hibernate, i'm working on converting this query to hibernate. since i am new to this technology right now, i wanted to request if the following few first steps are correct: 1. write POJOs for all the tables ...

40. cannont use select distinct(substring(convert))

select distinct substring(convert(varchar, table0_.Date, 120)) as col_0_0_ from Table table0_ order by table0_.Date ...

42. Converting org.hibernate.Query to Criteria

44. how to convert sql query to hql format?

I want to convert the following query from SQL to HQL. SELECT student.first_name AS student_first_name, AS course_name, AS course_id, admission.admission_no AS admission_admission_no, attendance.status AS attendance_status, case WHEN attendance.status=1 THEN 'P' WHEN attendance.status=2 THEN 'A' End as Status, count( as Periods, count(attendance.status) as Total, time_table_item.tt_date AS time_table_item_tt_date, attendance.student_batch_id AS attendance_student_batch_id FROM public.time_table_item time_table_item INNER JOIN public.attendance attendance ON = ...