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
0
votes
1 answer
Error in Hibernate NamedQuery
I'm sure this is something stupid, but I can't figure out why Hibernate is upset with my named query. Can someone please help me? Here's my query and the domain objects in reference, followed by the stacktrace.
@NamedQuery(name =…

Fast Old Man
- 95
- 3
- 13
0
votes
2 answers
org.hibernate.HibernateException: Missing column
I am using Spring 3 and Hibernate 4 in my Application with Maven. I am getting some issues which are due to Hibernate Mapping so i am working on it. But now i am stuck and unable to find the solution. please correct me if i am doing something wrong.…

AskSharma
- 187
- 2
- 7
- 15
0
votes
1 answer
Mapping entity to pojo with aggregation with Hibernate
I'm trying to create a list of POJOs from a NamedQuery that accesses an existing entity using Hibernate. I want to total the values in a mapped object into a "summary record" to use in a reporting structure of sorts, which is detailed below as…

Fast Old Man
- 95
- 3
- 13
0
votes
2 answers
Hibernate generating a query from Named Query that joins on the wrong column?
I am using named query (hibernate 4).Entity defined as below.
@Entity
@NamedQuery(
name = "findAllProduct",
query = "SELECT PC.pincode,PO.description"
+" FROM PRODUCT_VENDOR_PAYMENT_OPTION_LOCATION PVPOL"
…

AskSharma
- 187
- 2
- 7
- 15
0
votes
1 answer
Hibernate Named Query Outer Join
Let's say I have the following tables:
TABLE1:
ID number
NAME varchar
TABLE2:
ID number (foreign key from first table)
KEY varchar
VALUE varchar
Table 2 could have records for elements in table 1, but not always.
I need a Named Query that will get…

Martin
- 3,018
- 1
- 26
- 45
0
votes
2 answers
JPA NamedQuery to obtain a referenced object without executing join
Say I have three entities: Customer, Product and Order. Each Order has a ManyToOne association to a Customer and a ManyToOne association to a Product. Associations are unidirectional from Order to Customer and to Product respectively. So the…

user1781028
- 1,478
- 4
- 22
- 45
0
votes
1 answer
Issue with using timestamp field in named query
I am working on Eclipselink named query and have issues in setting optional parameter for timestamp.
My requirement is to query data with timestamp if the field is entered by the user. As the field is optional, I am checking for ''0000-00-00…

user2455158
- 97
- 3
- 12
0
votes
1 answer
NHibernate named query and 2nd level cache
I have the following mapping

Herman
- 3,004
- 5
- 37
- 49
0
votes
2 answers
Nhibernate Named SQL Query
Can any body tell me what is wrong with below query Named SQL Query using NHibernate.
As I am getting error - "Error in Named Query : GetSecondReviewIncomeStatements ":

Shubh
- 11
- 4
0
votes
1 answer
JPA named query cannot be resolved with Hibernate
I have added new named query:
@Entity(name = "books")
@NamedQueries({
@NamedQuery(name = "books.findByCategoryId",
query = "SELECT DISTINCT b.* FROM books b WHERE b.categoryId =:categoryId")
})
public class Book implements…

Alexandr
- 9,213
- 12
- 62
- 102
0
votes
1 answer
NamedQuery returning object instead of column
Hi I have a namedquery defined as below but when I execute it it retunrns me the whole object rather than just the fields that I have requested. Is there something that I am missing when I only want to return just a column of that object. Thanks in…

user1107753
- 1,566
- 4
- 24
- 36
0
votes
1 answer
Multiple JPA queries error
I want to run multiple queries using @NamedQueries annotation but it is giving error that :
1. The attribute value is undefined for the annotation typed NamedQueries
2.NamedQueries can not be resolved to a type
Following is the code:…

RK.
- 973
- 5
- 19
- 45
0
votes
1 answer
Using NamedQueries to query an encrypted column
I have a java app with JPA and I'm using oracle DB.
One property of an entity needs to be encrypted before saved into the DB.
I'm using application encryption, Base64.
I have a named query searching for the entity according to this property.
Now due…

user2307713
- 1
- 1
0
votes
1 answer
jpa 2 query to retrieve data using join table
I have table structure as follows
table user: iduser, firstName, lastName, username, email, dateJoined, dateOfBirth, password
table tag : idtag, tagName
table post: idpost, title, content, iduser, date, dateCreated
table post_tag : idpost, idtag…

Prasad Kharkar
- 13,410
- 5
- 37
- 56
0
votes
1 answer
What JPA Named Query can I use to access a ManyToMany join?
I have a JPA entity called 'Order'. When an Order is 'renewed' (copied with minor changes), I store a reference to the original Order in the 'renewed' Order.
JPA Entity reference:
@ManyToMany
@JoinTable(name = "OP_ORDER_RENEWAL", joinColumns =…

Jrokisky
- 65
- 1
- 10