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
2
votes
4 answers

PostgreSQL 9.4, use earth_distance in my JPA namedQuery

I had a table site stored my sites information with latitude and longitude. ozssc=> \d site; ...... site_latitude | double precision | site_longitude | double precision | ...... I added to my PostgreSQL…
cidy.long
  • 417
  • 12
  • 35
2
votes
1 answer

oracle query failing in in-memory hsqldb in oracle syntax mode

The following query fails in hsqldb 2.3.2 with sql.syntax_ora=true. Works fine in Oracle 11. It's a hibernate named query, used in a TestNG test going to in-memory hsqldb instead of the real Oracle. Error message is:…
labrat43
  • 49
  • 1
  • 5
2
votes
1 answer

Join in @NamedQuery: Unexpected token ON

In Hibernate, I created a query using JOIN to join two tables. The query executes fine in Oracles SQL Developer. However, if I add it to a @NamedQuery, the server starts with this error: Error in named query: loadFooByAnother:…
user1438038
  • 5,821
  • 6
  • 60
  • 94
2
votes
2 answers

Issues with bidirectional OneToMany mapping and NamedQuery

I have two entities connected bidirectional and I want to query the Location and its votes only for a specific date. Location: @Entity @Table(name = "TAB_LOCATION") @NamedQueries({ @NamedQuery(name = "Location.getVotedLocations", query = "SELECT…
CSchulz
  • 10,882
  • 11
  • 60
  • 114
2
votes
1 answer

JPA fetch from multiple tables to single POJO with named query

I have been trying to fetch data from 2 different tables to a single entity in JPA but with no result. The entity that keeps data from two different tables is as below : @Data @Entity @JsonSnakeCase public class WareHouse { @Id …
gaganbm
  • 2,663
  • 3
  • 24
  • 36
2
votes
4 answers

JPA: Errors in named query

I get the exception org.hibernate.HibernateException: Errors in named queries: ElaborazionePagamentiMaggioriOneri.estrai but the named query looks correct to me. I also get org.hibernate.hql.ast.QuerySyntaxException:…
Vitaly Olegovitch
  • 3,509
  • 6
  • 33
  • 49
2
votes
1 answer

Hibernate -- Criteria vs named query

I'm trying to compare Hibernate Criteria to named queries for performance. i'm aware it all depends on the actual query itself and the last word is on how they profile in runtime. still, trying to sort out what goes into each. i tried to organize…
Roam
  • 4,831
  • 9
  • 43
  • 72
2
votes
1 answer

JPQL count returning 0 when there is a row

I am using two identical JPQL NamedQueries, except that one is a COUNT. Here are the queries: select i from IssueRingReqsBrit i where i.ringDataRequest = 'I' and i.onRingIssue = 'Y' and i.noCardIssued = 0 select COUNT(i) from IssueRingReqsBrit i…
MasNotsram
  • 2,105
  • 18
  • 28
2
votes
1 answer

NamedQuery join and filter collection

I've tried to do this query but it still selects every child even though I just want the ones with the specific name. How would I achieve that? @NamedQuery(name="Parent.getChildrenWithName", query="SELECT p FROM Parent p " …
Lucas Arrefelt
  • 3,879
  • 5
  • 41
  • 71
2
votes
2 answers

Java: How to map results of Hibernate Named SQL Query (in XML file) to an annotated Entity

I'm trying to map the results of a Hibernate Named SQL Query (stored in an XML file) to an annotated Entity object. I've read through countless docs and tutorials and support threads but I still can't seem to get it working. Here's what I've got so…
Shaun Scovil
  • 3,905
  • 5
  • 39
  • 58
2
votes
2 answers

Using a named query in a hbm with import class

In my MSSQL server I have a SQL view called AllFavourite. In order to load the data into my DTO class I have the following in my hbm.xml file...
Rippo
  • 22,117
  • 14
  • 78
  • 117
2
votes
0 answers

Why is NamedQuery always returning cached results (stale data)

I seem to have an odd caching problem (I guess) for NamedQuery which I can not seem to resolve. Here are some details: I have a Process, ProcessForm and ProcessFormModule tables and related entities - which are all linked using standard @JoinColumn…
daxur
  • 359
  • 1
  • 11
2
votes
0 answers

Netbeans CRUD generator: customization and is it efficient for real applications?

I use netbeans 7.2.1. Is JSF CRUD Generated code efficient for real applications? I have created a test database and used netbeans CRUD generator. It uses DataModel and PaginationHelper instead of Lists for CRUD operations. There is an Entity…
2
votes
1 answer

Storing Complex Query as Named Query

I'm doing a project using JSF 2 and I have a particularly complicated query that does movie suggestions. I tried to put it as a named query and the compiler told me there was an error and I honestly have no idea where to look SELECT M.* FROM Account…
Phillip Huff
  • 555
  • 1
  • 6
  • 19
2
votes
1 answer

Java EE NamedQuery and JOIN statement - results in EJB Exception

I have an entity called Lots as follows: public class Lots implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private int lotId; @ManyToOne private Boats boats; private…
Paul Blundell
  • 1,857
  • 4
  • 22
  • 27