Questions tagged [named-query]

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.

521 questions
0
votes
1 answer

Get count from query

I am using mysql 5.5 with openjpa 2.3.0. I have entities with namedQueries (generated in netbeans - I would like to be able to use this), for example: @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u") @NamedQuery(name =…
Zavael
  • 2,383
  • 1
  • 32
  • 44
0
votes
1 answer

HibernateException: Errors in named queries: what is the possible cause?

I have an issue with named queries. Firstly, I want to understand a possible set of causes that can be a reason (something beyound syntax errors). Secondly, I would be glad to hear your queses about possible solution. Thanks in advance. I have a…
Mr Kohn Doew
  • 277
  • 1
  • 2
  • 18
0
votes
1 answer

error casting with eclipselink and @namedquery

For some time I have a problem in eclipselink mapping . I have two classes , Acordo and ValorAcordo. so I have @ Entity @ Table ( name = " TB_ACORDO " , schema = " JUR " ) @ NamedQueries ( { @ NamedQuery ( name = " sql1 " query = "…
petrov
  • 11
0
votes
3 answers

Selecting records based on date from MySQL

I have two columns in my table say Id, date. date is date timestamp (eg:2014-04-01 02:30:00). I want to return all the records based on the date (2014-04-01) instead of giving entire time stamp. How can I achieve this?
user2542428
0
votes
1 answer

"expected NUMBER got binary" exception occurred during data retrieval

Below is the Entity class Node { Long id; Node parentId; } hibernate named query using : select n from Node n where n.parentId.id = :id param value passing is null , i mean "id" passing is null and getting the exception " Expected…
Bravo
  • 8,589
  • 14
  • 48
  • 85
0
votes
0 answers

Java Hibernate Named query not known

Hi I am trying to use anotation to do named query. The line that caused Named query not known is: HibernateUtil.openSession().getNamedQuery( "getWorkById") Here is all the code about my named query. Actually I also tried to do…
user1385809
  • 21
  • 1
  • 2
0
votes
1 answer

JPA Re executing same namedQuery with different parameters

I'm using openJPA as implementation, and i'm facing the following issue. In one of our services, we use a namedQuery to select value in a range, so something like that: query = "select xxx from xxx where xxx in (:param)" This service / query is…
kij
  • 1,421
  • 1
  • 16
  • 40
0
votes
1 answer

use javax.persistence.Query in hibernate 4.2.3

I use hibernate-4.2.3 and i will run my first NamedQuery. i create it as below: @NamedQuery(name="LoadUserWithEmail",query="select u from User u where email=:email") after that i get it with session.createNamedQuery: SessionFactory…
Rasoul Taheri
  • 802
  • 3
  • 16
  • 32
0
votes
1 answer

Named queries in webservices

I want to retrieve all records with shelfId=1 and between two dates. I wrote a query like this in my webservice Its not working. can anyone please correct this one. @NamedQuery(name = "BinEnvironment.BinEnvironmentByStartDateEndDate", query =…
user2542428
0
votes
1 answer

propertyMissing doesn't work in Criteria?

So I've got a couple of classes with the following relationship: class Foo { Bar bar /* ... other fields ... */ } class Bar { String name } In class Foo I've got a couple of named queries: static namedQueries = { userFoos {…
Charles Wood
  • 864
  • 8
  • 23
0
votes
1 answer

HIbernate org.hibernate.HibernateException: Errors in named queries

Hi don't understand the problem with namedQuery getting exception HIbernate…
0
votes
1 answer

Second call of stored procedure throws ORA exception

I am calling a stored procedure in an Oracle database via Nhibernate in my app. The first time I call it everything works fine and I get a result but the second time I get an ORA-00942 (table or view does not exist) exception. Any idea what could be…
a.farkas2508
  • 357
  • 3
  • 12
0
votes
3 answers

How to create variable pattern matching for database lookup?

I'd like to find a table row where the desired value has the form of A9-B19-C12-D1. Thus, variable letters followed by variable digits, devided by - each. The length is not fixed, eg it could also be only A9 or A9-D1. I only care about the letters.…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
0
votes
2 answers

JPA: Invalid use of anyOf() for a query key

I've a OneToOne relation between Participant and abstract entity. I want to query for Participant that has an abstract. So I create the following query: @NamedQuery(name = Participant.FIND_ABSTRACT, query = "SELECT p FROM Participant p WHERE…
Enrico Morelli
  • 185
  • 3
  • 16
0
votes
1 answer

Define Dynamic Named Query in Entity Class

I have a named query as below; @NamedQuery(name = "MyEntityClass.findSomething", query = "SELECT item FROM MyTable mytbl") Now I need to append dynamic sort clause to this query (based on UI input params) So my question is can I still define the…
copenndthagen
  • 49,230
  • 102
  • 290
  • 442