Questions tagged [hql]

Use this tag for questions concerning "Hibernate Query Language" (HQL), a query language used by Hibernate and NHibernate. Use the tag [hiveql] for questions about Hive Query Language.

HQL, acronym for "Hibernate Query Language", is a powerful, object oriented query language used by the Hibernate and the NHibernate object relational mappers.

It is used in Java environments and is heavily inspired by SQL. Its syntax resemble SQL queries, but operate against Java Persistence API (JPA) entity objects rather than directly with database tables.

HQL can also be used on platforms such as Adobe ColdFusion

4854 questions
1
vote
2 answers

How to update with inner join in HQL

How to update with inner join in HQL ? My query in SQL like this update u set u.name = t.name from User u inner join Temp t on t.id = u.id and I try in HQL like @Query(" update User u set u.name = ..?.. where u.id in (select id from…
methodplayer
  • 43
  • 1
  • 8
1
vote
1 answer

Querying an Oracle Date field using a string in NHibernate HQL

I'm trying to query a .NET DateTime property and compare it with a date string like so: SELECT cat FROM mydll.cats AS cat WHERE cat.BirthDay > '1999-02-20' When I'm trying to search by a date string (without the SetDate function) The query won't…
Pavel Tarno
  • 1,264
  • 1
  • 11
  • 28
1
vote
2 answers

Error while executing hql query

I am getting an error while executing a hql query using Query query = session.createQuery(q); My query is select AU_USER from AU_TABLE where AU_ID in(010012025160151756912703600209,010012025160150254316794700103) The stacktrace is 2018-07-06…
Vishal Sharma
  • 173
  • 1
  • 2
  • 16
1
vote
0 answers

table with column idEntity fails query

I have a table with a column named "idEntity", if i run this query: select idEntity from algo.AUDITORIA ; in oracle, there's no problem and the query runs, but in SqlServer I'm getting: Incorrect syntax near the keyword 'from'. it seams that…
Alfredo M
  • 538
  • 2
  • 6
  • 24
1
vote
0 answers

HQL, use @ in alias

I'm trying to run this query SELECT userType from Users as @type But hibernate throws a syntax error. org.hibernate.QueryException: unexpected char: '@' I tried to use quotes but it didnt work as well. Can this be done?
Fabio K
  • 965
  • 3
  • 11
  • 20
1
vote
2 answers

HQL IN operator, Array of Enums ClassCastException

Here is my stripped down class and enum. class A { @Enumerated (value = EnumType.STRING) AType type; } enum AType { X,Y } if I run query = FROM A a WHERE a.type = :type query.setParameter("type", AType.X); All is fine and…
KyleT
  • 835
  • 1
  • 12
  • 18
1
vote
1 answer

how to generate hql query for OneToOne

i have brands class which is mapped as ONE TO ONE with Specification class MobileBrands.class: private int id; private String name; private int price; @OneToOne private MobileSpecification prodInfo; The MobileSpecification.class: private int…
Stone
  • 33
  • 9
1
vote
3 answers

java.lang.IllegalArgumentException: org.hibernate.QueryException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode

I am trying to trace this Exception but not understanding it, please look at my exception and please let me know where did I went wrong java.lang.IllegalArgumentException: org.hibernate.QueryException: No data type for node:…
bharath
  • 317
  • 1
  • 6
  • 24
1
vote
2 answers

how to optimize an HQL query that join two big tables

i have a HQL query like this one : Select foo From Foo foo, Bar bar Where foo.number = bar.number but it takes hibernate 4, 5 seconds to execute because the two tables are very big ones. and i did a tracing with Hibernate stat and trace log and…
xfocus99
  • 29
  • 5
1
vote
2 answers

partition list for the error "maximum number of expressions in a list is 1000"

I passed a list with more than 1000 elements in a HQL query and got this error maximum number of expressions in a list is 1000 I read several posts on Stackoverflow which suggests to partition the list into a few sub lists. Query query =…
user3369592
  • 1,187
  • 5
  • 16
  • 38
1
vote
0 answers

Escape special character in HQL query

I have following code public User findUser(){ User user = null; String userName = "People's Democratic"; String queryString = "SELECT user from User user where user.userName = :userName "; Map param = new…
Harshal
  • 847
  • 10
  • 20
1
vote
1 answer

Generating a method for linq in NHibernate for avg timespan

I'm trying to make avg for timespan work in linq for NHibernate. I've added registry: public class CustomLinqToHqlGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry { public CustomLinqToHqlGeneratorsRegistry() { this.Merge(new…
Archeg
  • 7,785
  • 5
  • 34
  • 81
1
vote
4 answers

Hibernate Named Query copy-pasting

In my .hbm.xml there are two queries. The first one retrieves number of records in the table:
Antonio
  • 10,838
  • 11
  • 54
  • 87
1
vote
1 answer

how to join two tables and get all matched record in hibernate(using entity class mapping)

I have two entities called FeeTerms.java and FeeTermDates.java I want to get all matched records from these two entities using pure HQL Look at entities: FeeTerms.java package com.rasvek.cg.entity; // Generated May 14, 2018 11:39:07 PM by Hibernate…
bharath
  • 317
  • 1
  • 6
  • 24
1
vote
0 answers

Convert SQL query to find ratio two sub queries into HQL

I am trying to convert following query to HQL: select x / total*100 from (select count( * ) as x from events e, publish_events p where e.event_id = p.event_id and e.amount <> 0 and e.creation_date > sysdate-2 and p.publish_status = 'xxxxxx' and…
1 2 3
99
100