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.
5,072
questions
0
votes
0
answers
45
views
Hibernate : Fetching data based on multiple table data status
@Entity
@Table(name = "service_staff")
public class ServiceStaff implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
...
0
votes
0
answers
29
views
Hibernate Java - Unexpected AST Node AND and =
I am currently writing a query on Hibernate 5.2.10.Final and keep on encountering Unexpected AST Node error, the query is here
SELECT
DISTINCT cs
FROM
CashbackSetting cs
LEFT JOIN ...
0
votes
1
answer
18
views
Getting date with max sales for a month
I have a table in Hadoop that I can count the number of sales for a specific month
select count(*) from sales where sold_date between '2023-08-01' and '2023-08-31'
How can I update this query to get ...
0
votes
0
answers
36
views
How register MetadataBuilderContributor in Spring Boot
Good afternoon! Who use MetadataBuilderContributor to register new function in HQL?
I work with Spring and QueryDSL.
I want to register new function to work with json through QueryDSL.
...
0
votes
0
answers
12
views
Multiple joins in HQL Query, duplicate instances of only one object in resulting collection
So I have following entities in a project I'm working (it's all huge so I will post a simplification):
public class A {
.
.
.
private String dateKey;
.
.
.
@ManyToOne
...
1
vote
0
answers
19
views
Why hibernate doesn't use my own join with entityGraph?
I want hibernate to use my own join (left outer join t.route Operations routeOperation) in its internal query. And now it turns out that in order for me to remove the n+1 problem, I need to add ...
0
votes
0
answers
62
views
Hibernate 6.2.1 and json navigation @Embeddable
I am using Wildfly 28, Hibernate 6.2.1
I want to use HQL to a Json Object like in this article: Hibernate 6.2.1 and json navigation
When i add @Embeddable, the following exception is thrown on ...
0
votes
1
answer
47
views
I have some questions about HQL syntax
guys. I'm a novice learning Hibernate.Recently,I learned some konwledge about Hibernate query language. When learned FROM systnx,I want to konw 'SELECT A FROM A' is same with 'FROM A'?
I ask for GTP,...
0
votes
0
answers
24
views
How to Convert MySQL Query with Function and View into HQL for Hibernate?
I have a working MySQL query that uses a custom function and a view to perform a spatial calculation. The function vParameterFunction() returns a point, and the view vTestView calculates the distance ...
0
votes
1
answer
27
views
Improve the performance of this windowing-heavy query
I have the below code in HQL. It's drawing data from a table with >2.5bn rows and around 334 columns. It takes a while to run so I'm looking for any potential performance boosts where possible. ...
0
votes
0
answers
13
views
Refer columns names from a hive table and resolve those values from another table
I have a table with customer's bank balances (All converted to USD) from different countries in a hive table as below.
Customer
US_BANK_BAL
CANADA_BANK_BAL
INDIA_BANK_BAL
ABC
10000
500
200
XYZ
3000
...
0
votes
0
answers
27
views
EntityManager is null if not created Manually
I work on a maven project which is deployed as a runnable jar on a server.
Unfortunately my EntityManager stays null if I not assign it manually.
Persistence.xml
<persistence-unit name="...
0
votes
1
answer
16
views
JdbcSQLSyntaxErrorException function DATE_ADD not found
I tried to use the MySQL function DATE_ADD in a nativeQuery
UPDATE my_table SET my_date = DATE_ADD(my_date, INTERVAL 1 HOUR)
but I got the error:
JdbcSQLSyntaxErrorException function DATE_ADD not ...
0
votes
1
answer
30
views
Hive query to find a month for each year in which maximum number of quantities were sold
I have a data like below, from which i am trying to find out which month for each year has max quantity ordered
if the data is not showing clearly i have added a snip of it
QUANTITYORDERED QTR_ID ...
0
votes
1
answer
33
views
How to pull data using SQL (HQL) code through the repository using 2 conditions
@Repository
public interface MeetupRepository extends CrudRepository<Meetup, Long> {
List<Meetup> findAll();
@Query(value = "select * from meetup join meetup_timetable "...
0
votes
0
answers
18
views
How to pull data using HQL code through the repository using 2 conditions
@Repository
public interface MeetupRepository extends CrudRepository<Meetup, Long> {
List<Meetup> findAll();
@Query(value = "select * from meetup join meetup_timetable "...
0
votes
1
answer
39
views
Round robin with record limitation
I have to build a hive SQL query for the following requirement
I have an customer table. I need to divide the total table record by 6 (i.e suppose table contain 600 records each month 100 record upto ...
0
votes
1
answer
236
views
JPA/Hibernate - Using Postgre's "ANY" Function in HQL
Context: Spring Boot Starter JPA Version 3.0.2, Hibernate Core 6.2.7.Final
Consider the following SQL tables and corresponding Hibernate entities:
CREATE TABLE person (
id INT PRIMARY KEY,
name ...
0
votes
1
answer
95
views
Returning list of strings in JPA @Query using projection
I have an entity Dog and then an entity of Event that the dogs participate in. I want to extract a list(string) of each Event that has a corresponding DogId. I am using JPA projection because I need a ...
0
votes
1
answer
56
views
Combine two queries into one
In the first query, I need to have the count for each type regardless of whether that’s read or not (unread can be true or false). In the second query, I need the count for all types only for when ...
0
votes
0
answers
48
views
JPA/Hibernate: how to re-use JPQL query
I have a somewhat complicated @NamedQuery that queries the following entity:
@Entity
class Employee {
@Id
String id;
LocalDate dateOfBirth;
String companyId;
}
It includes several joins and ...
0
votes
0
answers
14
views
Write a hibernate program to perform crud operations using query interface
Any crud operation related operation must be performed in the maven project and by using hql queries. This crud operation should be performed under query interface
I tried many to many mapping but ...
0
votes
0
answers
9
views
HiveOnSpark Performance tuning:why INSTR has much better performance than LIKE?
with t1 AS(
SELECT
date,
request_id,
maskdid,
query
FROM t_origin
),
SELECT
t2.query_like as `Query词`,
COUNT(DISTINCT request_id) AS pv,
COUNT(...
0
votes
0
answers
18
views
How to use subquery in a IN() clause in where part of HQL?
I have a simple class:
public class Chat {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id", nullable = false)
private Long id;
}
and a couple of ...
2
votes
1
answer
53
views
generate_series function in Hibernate
I have a column total in the table Inv and I want to extract total amount per month in hibernate using generate_series:
@Query(value = "SELECT _month," +
"sum(inv.total) AS ...
0
votes
0
answers
26
views
Query in HQL with multiple inputs for where clause
Let's say I have the following query "select myEntity where myEntityKey.value1= :value1 and myEntityKey.value2= :value2", and then let's say I have I receive multiple (value1, value2) pairs ...
0
votes
1
answer
41
views
How to write HQL using LEFT OUTER JOINs on multiple hasMany associations that doesn't expect all JOINs to be non-empty
In my Grails application I had defined a domain object called Order (mapped to a work_order table since order is a reserved word in MySQL) which has a one-to-many relationship with another domain ...
0
votes
0
answers
29
views
Hibernate+PostgreSQL - Attempting to retrieve join table/composite primary key information from database. No result found for query
I'm trying to further understand database retrieval.
My goal is to find the Category Name of a Film based on the film.id and make a query to find it. The result I got back is an error:
jakarta....
0
votes
0
answers
134
views
how to fetch 100k data with in a second in spring boot in this query
it takes too much time to fetch data.
after half an hour session out msg.
I want 100k data to fetch through ajax.
data increases day by day. after 1 year data across 400k then can not fetch data.
...
0
votes
1
answer
33
views
Prevent extra queries after performing join fetch when referencedColumn not matching the joinColumn
I have these entities where some values of ref_b may not match any row in table b.
class A {
@Id
@Column(name = id)
Long id;
@Column(name = "column_b")
private String ref_b;
...
0
votes
2
answers
25
views
How to know if a variable had a different mapping in a different time set
My question focuses on finding out if a variable was mapped differently in a previous time period.
I want to see if last month the place names could have switched (Example: Kansas was coming in for ...
0
votes
1
answer
296
views
Error converting valid SQL query into valid HQL
I'm running a SpringBoot Java application which is currently using hibernate-core 6.1.7.Final. I have a valid SQL query that gives me the results I need which I need to convert into HQL so my app can ...
0
votes
1
answer
409
views
How can I fix a ClassCastException in Hibernate when executing an HQL query?
I'm encountering a ClassCastException when executing an HQL query in my Hibernate-based application. The error message I'm receiving is:
java.lang.ClassCastException: class org.hibernate.hql.internal....
0
votes
0
answers
41
views
How to prevent Hibernate/JPA from translating column names in HQL queries?
I'm updating our applications from hibernate v5 to v6. This requires us to change our data access layer to use JPA queries instead of the hibernateTemplate ones we've had before (I know...).
An issue ...
0
votes
0
answers
90
views
Join alias not used into CASE WHEN on SELECT close
Consider these three entities:
@Entity
public class EntityA {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@JoinColumn(updatable=false, name="...
0
votes
0
answers
200
views
How to cast into a custom @Type (PersistentDateTime) in Hibernate?
I have mapped the statusDate field to org.joda.time.DateTime in the Foo class as follows:
@Column(name = "STATUSDATE", nullable = false)
@Type(type = "org.jadira.usertype.dateandtime....
0
votes
0
answers
88
views
How to change the value of innodb_lock_wait_timeout from hibernate
We are using AWS Aurora 2.x database ( compatible with MySQL 5.7 ). From our application, we are interacting with database using hibernate. In one scenario, we want to use a custom value instead of ...
1
vote
1
answer
35
views
nested max() function in a hql query
I want max((select max(c1) from t1 where cond1)), (select max(c2) from t2 where cond2), c3 from t3 where cond3). Is there a way to obtain this using hibernate/hql ?
I've tried with union:
SELECT MAX(...
0
votes
1
answer
59
views
How to get data from database one day previous on click
I'm building my app. I want to get documents from the DB when I clicked button 'previous'. Then the documents from the previous day should be displayed (e.g. 11 documents). When I click the button ...
0
votes
0
answers
40
views
Check if any hive table is missing from hql file in shell
I Have a requirement to check if ant table is missing from the hql file while the beeline query is getting executed from shell script!
Example :
beeline -u 'jdbc:hive2://server.domain.<>.com:...
0
votes
0
answers
236
views
Hibernate - Session.createQuery(String) returns null after upgrade
Upgraded an old application running Tapestry v5.4.5 -> v5.8.2, we get issues with Hibernate/HQL queries.
A query like this that used to work
session.createQuery("from MyEntity", MyEntity....
0
votes
1
answer
385
views
How to use Hibernate 6 short hand syntax to simplify JPA query?
According to this post comment, Hibernate 6 introduced support for the short hand syntax:
In Hibernate 6 we introduced support for the short hand syntax. For Hibernate 5 I believe that you have to ...
-1
votes
2
answers
321
views
How to create an index for a 'TEXT' column in a MySQL database by means of JPA/Hibernate
I need to create an index for a 'TEXT' column in a MySQL database. I can't do it using this annotation
@Table(name = "table1", indexes = @Index(name = "ix_table1_column1", ...
1
vote
1
answer
100
views
Hibernate run IN (VALUES ...) rather than IN query
I have a huge number of entities i need to load from the DB, i have a query like this
FROM ${entityName} x WHERE x.id IN :ids
the above generates SQL queries like this: ... where EntityName.id in (? ,...
0
votes
0
answers
108
views
How to set multiple values(or list/array) as a hive variable
I wish to declear a list of values and store it in a variable of sorts in hive and be able to call it later. see below. does hive variable do the trick?
Plan:
SET hivevar:periods = (202101, 202102, ...
1
vote
3
answers
353
views
incorrect SQL where clause generated from HQL since hibernate 6 using test on left join on where clause
Since I migrate to Hibernate 6 (5.4.30.Final to 6.2.0.Final), some of my queries is not translated correctly.
Here is a minimal reproduction project based on this tutorial:
Entities (getters/setters ...
0
votes
0
answers
126
views
How to fix missing org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory in hibernate 6
I am migrating spring framework from 5.* to 6. I am getting error:
hql is missing in
‘org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory’.
How to fix this?
I tried searching for the class in ...
0
votes
0
answers
10
views
HQL fetch parent by children attribute and fetch this child also
I have following problem,
Imagine we have two entites
Entity A
Entity B
Entity A has linked list of B entities like this
@ManyToMany(fetch = FetchType.LAZY,cascade = [CascadeType.REFRESH, CascadeType....
1
vote
2
answers
245
views
how to change the partitioned column datatype?
Consider I have the below table:
CREATE EXTERNAL TABLE sales (
id INT,
name STRING,
amount DOUBLE
)
PARTITIONED BY (CITY INT);
In the above table when i try to alter the non-partition datatype, I can ...
0
votes
0
answers
70
views
Caused by: org.postgresql.util.PSQLException: ERROR: column "generatedalias0" does not exist or "must appear in the GROUP BY" in query with no group
I have 2 entities like that:
@Entity
@Table(name = "registry_groups")
public class RegistryGroupEntity {
@Id
@SequenceGenerator(name="registry_groups_gen", sequenceName=&...