Questions tagged [hql]

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 operates with Java Persistence API (JPA) entity objects rather than directly with database tables.

HQL can also be used on platforms such as Adobe ColdFusion

5074 questions
1
vote
1 answer

Forward Rolling Average in Hive Query

I want to calculate the rolling average looking forward on "4 day window" basis. Please find the details below Create table stock(day int, time String, cost float); Insert into stock values(1,"8 AM",3.1); Insert into stock values(1,"9…
Raj
  • 401
  • 6
  • 20
1
vote
3 answers

Fetching records from the MySQL database from 10 tables

I have a database with 20 tables inside it. I want to fetch records from 10 related tables at a time, and I am using Hibernate. What is the best solution: to write a single query using join with select, or write 2 or 3 simple queries? I want to…
subodh
  • 6,136
  • 12
  • 51
  • 73
1
vote
2 answers

Why HQL generated with hibernate version 5.2.17 has '_id' appended with all the columns which has associations

I was trying to migrate hibernate from 4.3 to 5.2. The problem i am facing is HQL generated with version 5.2.17 has '_id' appended with all the columns which has associations. public class Person { private Long id; @ManyToOne(cascade =…
1
vote
1 answer

How do i use reserved table column in hibernate @Formula

I'm trying to use column name that is a reserved keyword in hibernate. Even with quotes i'm still getting errors. I need to create a subquery using @Formula. Table looks like this below, notice the column named "row", we are querying this from an…
Tom Bombadil
  • 53
  • 1
  • 6
1
vote
0 answers

HQL: select from JSON

I have this class: class School { private Map questionnaire; } ... Questionnaire is stored in my db as a VARCHAR(MAX) json and I would like to query it like this: select sch from School where sch.questionnaire['5'] like…
1
vote
2 answers

combine multiple group by queries into single query

I have a table similar in structure to the one below, I have four grouping variables (Region,Site,Method,Client) and three metrics that each have an accompanying "bucket" column that gives the quintile of the metric. I would like to perform some…
hghg hghg
  • 127
  • 9
1
vote
1 answer

Time Difference Calculation in HIVE gives wrong answer

Computing time-difference in HIVE and need it in hours:minutes:seconds. The answer I am getting is not quite right. This is the query I have tried SELECT from_unixtime(UNIX_TIMESTAMP('2019-01-01 12:00:00') - UNIX_TIMESTAMP('2019-01-01…
user2510479
  • 1,528
  • 13
  • 17
1
vote
1 answer

temporary Table in hql

my query is like : with bigQuery as ( ) select * from bigQuery ; how to write it with HQL ??
Ahmed
  • 25
  • 1
  • 5
1
vote
2 answers

how to combine show partition query with select statement to get the latest partition with the table name

I am looking for a hive/SQL query that gives the output in such a way it prints both the table name and the partitions respectively... Or similar query which executes fast and gives the latest partition and the table name SELECT 'table1' AS…
Codeit
  • 21
  • 3
1
vote
4 answers

Second replacement of a named parameter fails in HQL

I have an HQL statement of this sort: update versioned MyTable t set t.myCol = case when ((t.myCol + :myColChange) < 0) then 0 else (t.myCol + :myColChange) end I see that this is not working due to the second occurrence of :myColChange.…
pall
  • 345
  • 3
  • 7
1
vote
1 answer

Using count within another select

I get this exception: :0:0: unexpected AST node: query right-hand operand of a binary operator was null :0:0: unexpected end of subtree right-hand operand of a binary operator was null While running this HQL query select p.nicenumber…
T. Tom
  • 69
  • 1
  • 6
1
vote
1 answer

Equivalent of GREATEST() in HQL

I'm trying to find the greatest of two dates in HQL. In SQL this works: SELECT ( GREATEST(a1.startDate, '2019-10-01T00:00:00Z') ) FROM Activity AS a1 WHERE a1.id = 66232 But the equivalent in HQL gives me the following…
1
vote
0 answers

Spring Data JPA @Query with spel in a IN query List of Object

@Query("FROM GroupUserItemFGA fga WHERE (fga.identity.itemCode,fga.identity.dataAccessLevel) IN (:#{#fgaCombination.itemCode},:#{#fgaCombination.dataAccessLevel})") public List findFgaBasedFga(@Param("fgaCombination") List
pratik deshai
  • 2,770
  • 2
  • 11
  • 13
1
vote
1 answer

JPA @Query select on oracle throws ORA-01722: invalid number on string

I have the following query that works perfectly with ms-SQL but failing with oracle there is sample query, the original is way complicated but this one reproduces the error @Query("SELECT new Map((s.name + ' - ' + s.name) as name , s.idStandard as…
Happy Coder
  • 1,293
  • 1
  • 19
  • 35
1
vote
2 answers

Select SQL query that fill the missing value from another select

I have the table user1 : id |date 1 2018-01-01 2 null 3 2018-01-01 4 null and another table user2: id |date_buy 1 2018-01-01 1 2018-01-02 2 2018-01-01 2 2018-01-02 3 2018-01-01 4 2018-01-01 I…
Omegaspard
  • 1,828
  • 2
  • 24
  • 52
1 2 3
99
100