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
0 answers

Caused by: org.hibernate.QueryException: Could not resolve requested type for CAST : INT

Caused by: org.hibernate.QueryException: Could not resolve requested type for CAST : INT [ SELECT SUBSTRING(referenceComptable , 8, 14) AS seqNum, SUBSTRING(referenceComptable, 4,7) AS yearCegid, SUBSTRING(referenceComptable, 1,3) AS journal…
P.K
  • 35
  • 1
  • 6
1
vote
4 answers

Hibernate Lazy Initialization exception even using Join Fetch in HQL queries

I want to initialize a collection with lazy fetch mode and use Join Fetch in my queries but I some times(not always) face with lazy initialization exception ??? org.hibernate.LazyInitializationException: failed to lazily initialize a collection…
M2E67
  • 818
  • 7
  • 21
1
vote
2 answers

Java Hibernate java.lang.IllegalArgumentException: Unknown parameter position: 1

This is my query method : @Query(value = "select new com.twognation.hub.dto.GameDTO(game.id, game.name, game.active, game.description, game.coverImage, game.logo, game.backgroundImage, game.featuredImage, game.characterImage, game.smallCoverImage,…
user3364181
  • 371
  • 1
  • 10
  • 26
1
vote
0 answers

How to properly create a Spring JPA query using HQL?

If I run this query on my db it works fine: UPDATE Products SET in_Stock = (quantity_in_stock is not null and quantity_In_Stock > 0) WHERE id = 1 and deleted_At is NULL; But I'm using Spring JPA and trying to create this same query like…
Igor
  • 1,297
  • 3
  • 19
  • 49
1
vote
1 answer

Write HQL UPDATE query with generic type

I have a generic tokenRepository interface : public interface TokenRepository { @Modifying @Query("UPDATE T_token as a SET a.revocationReason = :reason WHERE a.id = :id") void revokeByTokenId (@Param("id") T_id…
jeremieca
  • 1,026
  • 1
  • 12
  • 33
1
vote
2 answers

JPA Query: join a subquery with grouping condition

I have an entity that represents a change event for a specific object. Something like: @Entity public class Event { @Id private String eventId; private String objectId; private Instant creationDate; // other fields, getters,…
Sasha Shpota
  • 7,441
  • 6
  • 49
  • 100
1
vote
0 answers

hive error with partition by

Here is my create table CREATE TABLE parquetpoc.employee USING PARQUET LOCATION '/mnt/adlsQA/parquetPOC/output/employee' PARTITIONED BY (`snapshot_year_month` string,`snapshot_day` string) In the PARTITIONED BY I have tried, quotes, single quotes,…
test acc
  • 461
  • 1
  • 8
  • 19
1
vote
4 answers

use Limit on HQL query

I have a HQL Query in JpaRepository: public interface LineRepository extends JpaRepository{ @Query( value = "SELECT l from LineEntity l" + "WHERE l.lineCode = :lineCode " ) …
Morteza Jalambadani
  • 1,881
  • 5
  • 19
  • 30
1
vote
4 answers

Hibernate HQL with list getters

I have a Hibernate entity, with a getter that is mapped as a @OneToMany: @Entity class Parent extends BaseParent { @OneToMany(cascade = {CascadeType.ALL}, mappedBy = "parent") public List getChildren() { return…
Joe
1
vote
1 answer

Errors in named queries

I get this error message: HibernateException: Errors in named queries: History.findByWeekId My entity class looks like this: @Entity @Table(name = "xyz_History") @NamedQueries({ @NamedQuery(name =…
GarfieldKlon
  • 6,580
  • 6
  • 24
  • 28
1
vote
1 answer

HQL and grouping

After much problems with using 'group by' in linq2nhibernate, I have tried to switch to HQL, but I am struggeling with a simple example. I have the following table (ForumThreadRatings): I would like to retrieve a list of the highest rated forum…
Dofs
  • 13,655
  • 25
  • 72
  • 120
1
vote
0 answers

HQL Hibernate INNER JOIN SUBQuery

I have some experience in SQL, but my knowledge in HQL is limited Here is my SQL query select * from (select * from readings join (select max(signal) as signal,sender as mac ,receiver as rc from readings where created_datetime …
Koushik Paul
  • 685
  • 6
  • 10
1
vote
1 answer

How to create query in HQL for one to many mapping

I have two entity as below public class Author{ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "author") @Fetch(FetchMode.SUBSELECT) private Set books; } public class Book{ @ManyToOne …
Mujahid
  • 121
  • 2
  • 9
1
vote
2 answers

Select table row using HQL with param

I want to use this HQL query in order to select table row value: String hql = "select e.token, e.name from Terminals e where e.token = ?"; Terminals terminal = entityManager .createQuery(hql, Terminals.class) .setParameter(0, terminalToken) …
Peter Penzov
  • 7,110
  • 86
  • 300
  • 595
1
vote
1 answer

hibernate, mysql

i have the following hql query: UPDATE TaskAssessment taskAssessment SET taskAssessment.activeFlag = false WHERE taskAssessment IN ( SELECT taskAssessment2 FROM TaskAssessment taskAssessment2 Where taskAssessment2.activeFlag = true AND…
Ikthiander
  • 3,737
  • 8
  • 33
  • 54
1 2 3
99
100