subselect « Query « JPA Q&A





1. Convert SQL-query with subselect in select section to HQL    stackoverflow.com

I have trouble with converting native SQL query to HQL. Query is something like follows:

select count(*)
, sum(select count(*) from employee e where e.company_id=c.id)) 
from company c where c.id = someID
First returned value ...

2. Nhibernate HQL Subselect queries    stackoverflow.com

I have the following SQL query:

select c.id
from (select id from customers) c
This query has no practical value - I simplified it greatly for the purpose of this post. My question: is it ...

3. Converting SQL with subselect in select to HQL    stackoverflow.com

I have the following SQL that I am having problems converting to HQL. A NPE is getting thrown -- which I think has something to do with the SUM function. Also, ...

4. How to convert SQL- Query with subselect into HQL Query?    stackoverflow.com

I would like to convert following Query into HQL Query. How can i do? select * from gpsdata where mobileunitid = '2090818044' and gpsdate in (select gpsdate from gpsdata where mobileunitid = ...

5. Hibernate HQL update with a subselect in set clause    stackoverflow.com

I'm trying to do an update in hibernate HQL with a subselect in a set clause like: update UserObject set code = (select n.code from SomeUserObject n where n.id = 1000) It isnt ...

6. Hibernate criteria api 'Select in'    stackoverflow.com

is it possible to create a 'select in'-query with the hibernate critiria api ? Example : I have two tables in a 1:n relation, company and department

select * from company c where c.id ...

7. Subselect queries in Hibernate    coderanch.com

I am new to hibernate. Please can someone tell me what I am doing wrong with the following query. (I am using OracleDialect) String sql = "select task from Task as task where task.taskName = :tName " + "AND task.taskMessage = :tMessage AND task.dateTime > (select processMonth from lu_process_month)" Task is a peristence object with getter and setters for the properties ...

8. Hibernate: Criteria Query with Subselect    coderanch.com

Hello, I have a working HQL query that I'm trying to convert to a QBC. The HQL is below. I've taken several stabs at the QBC, and I've included my attempts, too. Any help getting this working (along with an explanation) would be superb! Thanks! Lavie This returns a list of Task objects. from Task t where t.loc.locSeq = :Location and ...

9. Subselect in SELECT clause with Criteria Query    forum.hibernate.org

I believe that what I need is a Projection. I don't see a built-in one in the Projections factory, but I am guessing that if the API can generate the SQL for subqueries in the WHERE clause it would not be much work to extend in to the SELECT and/or FROM clause. I am going to give it a shot. Any ...





10. HQL - how create select with join from subselect    forum.hibernate.org

11. Avoiding subselect when querying many-to-many    forum.hibernate.org

13. Order by clause not working correctly when usng a subselect?    forum.hibernate.org

Author Message matt.moore Post subject: Order by clause not working correctly when usng a subselect? Posted: Tue May 31, 2005 4:37 pm Newbie Joined: Wed May 18, 2005 4:26 pm Posts: 6 I am using a subselect to simulate a view, the order by clause does not seem to be working correctly, did I do something wrong? Any help ...

14. HQL query with an unmapped object in a subselect possible?    forum.hibernate.org

I am getting a "QuerySyntaxError

is not mapped." error because I am including an unmapped table in a subselect of an HQL query. For me it is undesirable to create an object mapping for this table since it is being used only for filtering the results. The gist of code is below: Code: List myList = Carma.getHibernateConnector().getSession() .createQuery("from ...

15. Problem with distinct in subselect    forum.hibernate.org

Hibernate version: 3.0.5 Database: PostgreSQL 7.4.8 Generated SQL: Quote: select company0_.id as id5_, company0_.companysize as companys2_5_, company0_.country_id as country3_5_, company0_.name1 as name4_5_, company0_.name2 as name5_5_, company0_.address1 as address6_5_, company0_.address2 as address7_5_, company0_.zip as zip5_, company0_.city as city5_, company0_.phone as phone5_, company0_.fax as fax5_, company0_.logo as logo5_, company0_.email as email5_, company0_.homepage as homepage5_, company0_.founded as founded5_, company0_.employees as employees5_, company0_.valid as valid5_, ...

16. Subselect in the projection, does it works?    forum.hibernate.org

Hi all, I'm quite new in the hql world and I'm trying to do a subselect in the projection but it doesnt work! I want to know if it's possible. Example: Code: SELECT (SELECT te2.nrDdi FROM TelefoneEndereco te2) as teste FROM com.mercurio.lms.configuracoes.model.TelefoneEndereco te WHERE te.enderecoPessoa = ? This code give me this error: 15:00:37,639 INFO [STDOUT] Caused by: ...





17. Subselect query    forum.hibernate.org

18. Wierd truncation of the rest of hql query after a subselect    forum.hibernate.org

Hibernate version: 3.1.2 Name and version of the database you are using: Oracle 9.2 Hi, I am executing a hql query that has a couple of subselects, and an order by clause. It is to search a database for people with a firstname, city, and email criteria. For some reason the generated sql has missing criteria after the email subselect. Here ...

19. Is there wayto use Subselect in Join clause(Derived Tables)?    forum.hibernate.org

Hibernate version: 3.1 Hi there.. im having trouble trying to convert this SQL that is running on Oracle to HQL.. Seens like we cant use subselects in the from clause.. is that it?? is that a way to do that?? any workaround???? select os.sgOrgaosetor, os.nmOrgaosetor , sum(saldoIni) saldoIni, sum(recebidas) recebidas, sum(encaminhadas) encaminhadas, sum(saldoIni)+sum(recebidas)-sum(encaminhadas) as saldoFim from (select T.cdOrgaotrami cdOrgaotrami,count(*) saldoIni,0 recebidas,0 ...

20. Inefficient Multiple Subselect Query?    forum.hibernate.org

I have the following query that I would appreciate any optimization advice. See explanation below. Code: select distinct new Map(sp.state as receive) from Coupling c join c.statePrevious sp where ...

21. HQL not support subselect in from clause?    forum.hibernate.org

22. How to SubSelect in Where clause?    forum.hibernate.org

This code: Code: Criteria criteria = getSession().createCriteria(Solicita.class, "solicita"); criteria.setProjection(Projections.property("solicita.numero")); criteria.add(Restrictions.eq("solicita.flgAprov", (byte)1)); Criteria subCriteria = getSession().createCriteria(InicCart.class, ...

23. Subselect with group by in a Criteria    forum.hibernate.org

24. SubSelect in from clause    forum.hibernate.org

We are using the Criteria exclusivly throughout our application. Each query we call list() to get the results. The criteria is limited by MaxResults and the FirstResult is set so that our results get paginated within the application. Then we remove the MaxResults and the FirstResults and add the Projections.rowCount() and call uniqueResult() on the Criteria to get the total number ...

25. HQL: subselect in query    forum.hibernate.org

26. subselect query    forum.hibernate.org

Hi All, Please help me implement the following query in hibernate. select count(col1),col2,col3 from tbl1 .................... .................. where ........... .............and col3 in (select distinct col4 from tbl2 where col_0 = ? and col_1 =?) group by col2 this above query is to be implemented using subselect : eg: select count(col1),col2,col3 from tbl1 .................... .................. where ........... .............and col3 in (select ...

27. Hibernate: Criteria Query with Subselect    forum.hibernate.org

Newbie Joined: Fri Oct 10, 2008 11:58 am Posts: 1 Hello, I have a working HQL query that I'm trying to convert to a QBC. The HQL is below. I've taken several stabs at the QBC, and I've included my attempts, too. Any help getting this working (along with an explanation) would be superb! I think the biggest issue I'm having ...

28. Does Hibernate support subquery (subselect) in "FROM" clause    forum.hibernate.org

Thanks fge & parag.gajbhiye... My query is like this: ------ select A.col1, A.col2, resultList.col1 from table1 as A outer join ( (select B from table2 as B where [condition]) as resultList ) ------ In the hibernate mapping, table B contains A's pk, hence they both can join. I tried in SQL, it worked (i need to write 1 more line, to ...