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

Mismatching return of a query with NamedQuery

Hi to all i'm new in J2EE world. I'm trying to use @Namequery to get a List of String from my model(the class is called Element), in this case the attribute name. Why when I use @NamedQuery(name="Element.findAllNames",query="SELECT e.name FROM…
Rotom92
  • 696
  • 1
  • 7
  • 20
0
votes
2 answers

Convert Named Query to Native Query

I have 2 separate tables mapped to SharedThing and TeamMember. I have the following named query; SELECT sharedThing FROM SharedThing sharedThing, TeamMember teamMember WHERE teamMember.sharedId = sharedThing.sharedId AND teamMember.userId…
copenndthagen
  • 49,230
  • 102
  • 290
  • 442
0
votes
3 answers

NamedQuery with resultClass parameter not returning expected "type" for the query result

I have the following named query; @NamedQuery(name = "Person.findSpecific", query = "Select p.name, p.age from Person WHERE ..." Query query = getNamedQuery("Person.findSpecific",Person.class); When I executed the code; List resultList =…
copenndthagen
  • 49,230
  • 102
  • 290
  • 442
0
votes
1 answer

getNamedQuery with explicit custom class

Say I have a Person model (Java class and Database table) which has columns/fields like name, age, gender, height, weight. Now there are 2 possibilities 1) I would need the entire column data..so i would have the named query …
copenndthagen
  • 49,230
  • 102
  • 290
  • 442
0
votes
1 answer

NamedQuery with multiples entities and get multiples attributes

I'm works with JPA and I'm doing query SQL but I don't know how to convert to namedQuery this is the query with sql: SELECT DISTINCT o.descripcion, t.descripcion , d.descripcion , e.numRegistrosReportados FROM…
Cristian
  • 1,480
  • 5
  • 32
  • 65
0
votes
1 answer

Implement pagination using Java (Named Query)

Here is the scenario. I had a page with a list of records shown all (without pagination). Now at the backend side, the records are retrieved with a combination of 2 separate named queries for each part (one each for actual records/count of…
copenndthagen
  • 49,230
  • 102
  • 290
  • 442
0
votes
1 answer

How do I prevent Runtime Exception in NamedQueries

How can I make a JUnit Test that tests NamedQueries? I want a fail on syntaxis error like: @Entity @NamedQueries({ @NamedQuery(name="Country.findByName", query="SELECT c FROM Country c WHERE c.wrongname = :name") }) public class…
Omar Hrynkiewicz
  • 502
  • 1
  • 8
  • 21
0
votes
1 answer

HQL NamedQuery with inner join on a HashMap

I am developing a JSF project and using Hibernate over mysql as you may know (it is in the Hibernate documentation), joins use associations between entities. So a sample correct query with an inner join will be : select from Person p join p.classes…
MoienGK
  • 4,544
  • 11
  • 58
  • 92
0
votes
4 answers

JPA @NamedQuery with two tables, possible?

I'm having a kind of dummy problem, I need to make a @NamedQuery with a join with other table, some simple thing. But in all my @NamedQuery I'm only dealing with my mapped Object/Table. For example in my Object/Table Mapped cars: @NamedQuery(name =…
rafa.ferreira
  • 1,997
  • 7
  • 26
  • 41
0
votes
0 answers

Java Hibernate NamedQueries memory Consumption

i have a query in Hibernate using criteria and the same criteria using namedQuery my question is why the named queries always used more memory than criteria(tested several times) the namedQuery is faster my shallow knowledge is when hibernate using…
chiperortiz
  • 4,751
  • 9
  • 45
  • 79
0
votes
1 answer

Named query-use and

I have read Named query. We can use < query> and < sql-query> in mapping file for named query. I cant understand the difference between < query> tag and < sql-query> tag. When we have to use < query> tag and when we have to use < sql-query>…
Viraj Dhamal
  • 5,165
  • 10
  • 32
  • 41
0
votes
1 answer

get multiple record in a list

Hii i am running a named query and in my table i have multiple notifications for a corresponding userid so i need to get these multiple notification in a list and then show on my jsp here is my code.. JAVA CODE public ModelAndView …
Nav Kumar
  • 141
  • 3
  • 5
  • 12
0
votes
1 answer

Grails filter domain class by property of another domain

I have a Grails application and want to create filters for my domain class using named query. I have domains Act and Status, StatusName is an Enum: class Act { static hasMany = [status : Status] } class Status { Date setDate StatusName…
TulaGingerbread
  • 435
  • 5
  • 15
0
votes
1 answer

Difference between @NamedQuery and @NamedNativeQuery in JPA-EclipseLink

Hi I am a newbie using persistence API, and have also read few posts related to the same and got a very few understanding between these two. the below post really helped me clear my concepts for @NamedQuery What is a named query? I now wanted to…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
0
votes
1 answer

Java EE Glassfish error compiling non existing named query

My problem is following: In one entity class I have added NamedQuery that didn't compile well at the time of application deployment to server. The problem was that I was using wrong entity name in it's JPQL statement, so I've decided to remove that…
cw3le
  • 1