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
19
votes
3 answers

Ordinal Parameter Not bound : 2 in @Query annotation

I am getting following error when I try to run this query. org.hibernate.QueryException: Ordinal parameter not bound : 2", @Query(value = "SELECT amu " + "FROM Upgrade amu " + "INNER JOIN FETCH amu.visibility…
user1474111
  • 1,356
  • 3
  • 23
  • 47
19
votes
2 answers

java hibernate: selecting the discriminator column in polymorphic hql query

In hibernate, I want to select the discriminator value. Something like select discriminator, id, name, age from Animal The idea is to send the result of this query to the client side, so that I can display a different icon based on the value of the…
flybywire
  • 261,858
  • 191
  • 397
  • 503
19
votes
1 answer

Hibernate is using wrong table name for order by expression with three level inheritance

In our project we have different user types presented by different classes. And we have a BaseEntity class as @MappedSuperclass. When we try to use user classes with InheritanceType.JOINED hibernate creates an sql that we think it is wrong. Base…
Ekrem
  • 483
  • 2
  • 16
19
votes
3 answers

HQL unexpected AST node: {vector}

I'm trying to write an HQL query to grab a list of users that belong to a particular organisation, or any franchisee from a list of franchisees, however hibernate isn't able to parse it. I can't figure out why. Here is the HQL: from User u where…
rcgeorge23
  • 3,594
  • 4
  • 29
  • 54
19
votes
8 answers

HQL to query records between two dates

I am trying to query all customers records using HQL in my Spring/ Hibernate app that have DateAdded between Date1 and Date2 OR LastSeen between Date1 and Date2, so I've build this HQL query in the Repository/ DAO…
MChan
  • 6,842
  • 27
  • 83
  • 132
19
votes
3 answers

Hibernate HQL Count Distinct not working?

I have the following classes: class User { hasMany = [ratings: Rating] } class Item { hasMany = [ratings: Rating] } class Rating { belongsTo = [user: User, item: Item] } I want to count the distinct users that rated on an item. The…
Michael
  • 32,527
  • 49
  • 210
  • 370
19
votes
2 answers

Using a join in a Hibernate HQL update query

i have the following hibernate mapping: