A Hibernate (and NHibernate) feature that allows for both HQL and SQL queries to be written in the mapping document, keyed by a name. The main advantage is that your query is now residing in the same place as the definition of your mappings, instead of in your Java/C#/VB.NET/... code.
Questions tagged [named-query]
521 questions
1
vote
1 answer
JPA @JoinColumn custom object type
I'm studying a project that uses JPA, which I'm pretty new at. I've encountered a logic that I'm not understanding quite well. I have an entity called A that has this field/column:
@Column(name = "COD_UOP_COO")
private String codUopCoo;
then I…

Usr
- 2,628
- 10
- 51
- 91
1
vote
1 answer
nhibernate NamedQuery from criteriaQuery --> help needed
I am trying to convert a working criteria query into a named query, and not getting the syntax right. The hql version apparently wants both the type and id params specified.
The query is over a class mapped with ANY (below also)
Can someone give me…

Berryl
- 12,471
- 22
- 98
- 182
1
vote
2 answers
How to declare named queries oustide Hibernate entity classes?
I have a data access class that exposes basic operations for an entity class used on a web site:
public class UserDataAccessService {
public User login(User u)...
public User findByUsername(String username)...
I want to define all HQL/SQL…

user646584
- 3,621
- 5
- 25
- 27
1
vote
2 answers
eclipse complains about my JPA NamedQuery
For some reason eclipse IDE complains about my JPQL @NamedQuery
Input parameters can only be used in the WHERE clause or HAVING clause
of a query.
and
An association field cannot be used in an update items path
expression.
this is my…

masber
- 2,875
- 7
- 29
- 49
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
- 11,170
- 7
- 31
- 33
1
vote
1 answer
hyperledger-composer query with "CONTAINS" operator not working
In my hyperledger-composer app with angular front-end I want to send a query to the REST server.
query selectEmployeesByProject {
description: "Select all employees with access to the specified project"
statement:
SELECT…

Tommy
- 699
- 4
- 11
- 26
1
vote
1 answer
Can't access a stand alone domain object in hql namedQuery
First I need to apologize for the long post, I struggle with being overly verbose and yet not always clear enough. I also have searched extensively for an elegant solution for my issue and if I missed it please direct me to it.
Some Background:
I…

rwheadon
- 241
- 1
- 12
1
vote
1 answer
How to fix Named Query Error ( unexpected token: DAY ) in Hibernate?
Following is my named query for finding activities older then 90 Days:
"DELETE FROM PAActivity pa WHERE pa.status IN (:statusSet) AND cast(pa.datoFinish as date) < cast(DATE_SUB(current_date(), INTERVAL (:noofdays) DAY) as date)"
During compile…

fatherazrael
- 5,511
- 16
- 71
- 155
1
vote
0 answers
JPA Named query having join with result of aggregate function not working
I have a query which works fine with SQL Developer but when I change it to Named query, it shows me exception. The join association path is not a valid expression. I have googled it a bit and found out that JPQL/JPA does not support subquery in from…

Deepak Gangore
- 343
- 1
- 13
1
vote
0 answers
Are criteria builder faster than named query?
I have two tables that looks like:
Table_0
ID Description
5 description5
6 description6
7 description7
8 description8
Table_1
ID Table_0_ID Status
1 5 LOADED
2 6 LOADED
3 7 LOADED
4 7 …

pikimota
- 241
- 1
- 4
- 15
1
vote
1 answer
How to send Column Name as parameter in Named Query
I'm writing a Named query to fetch data's based on yearly bases.
Query
SELECT * FROM table1
WHERE ((year1 > 0) OR (year2> 0 OR (beyondYear2> 0)));
The query is working fine. From JSP I'll be selecting the year, so for that particular year the…

Sam
- 513
- 1
- 11
- 27
1
vote
1 answer
How to create this entity named query
I have a notification service.Notification show to users depends on their permission.Notification is implemeted by the help of three tables they are Notification,Notification type(its Define notification type and its belogs to which permission users…

Araf
- 510
- 8
- 32
1
vote
1 answer
How to return Map as result from named nativ query in xml using JpaRepository
I need to query some count per day and i would like to create named native query that will return this in map. How can i do that ?
…

user3364181
- 531
- 3
- 14
- 32
1
vote
2 answers
How to search current date in Timestamp field of MYSQL using Hibernate Named Query (HQL)?
I tried to pass date using following way but unable to succeed.
dateAnswered is field which stores date as 2017-09-13 00:00:00.
Can anyone tell where i am getting wrong:
Way 1: SetParameter
@NamedQuery(name = "findAnswar", query = "SELECT a FROM…

Harpreet
- 186
- 1
- 1
- 10
1
vote
1 answer
Method query with multiple tables including ordering?
I'm not sure if I hit the boundaries of the method query with this task.
I have two tables, a User table and a Password table. A User may have multiple Passwords (Where as the newest one is the current).
I would like to make a method query in my…

Herr Derb
- 4,977
- 5
- 34
- 62