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

Strange behaviour when executing query on Oracle with EclipseLink

I created a namedquery as follows: SELECT o FROM TableName1Entity o , TableName2Entity a WHERE o.field1 = a.field4 AND a.field5 = :param1 That is converted to the following sql: SELECT TABLE_NAME1.FIELD1, TABLE_NAME1.FIELD2, TABLE_NAME1.FIELD3 FROM…
w35l3y
  • 8,613
  • 3
  • 39
  • 51
0
votes
1 answer

Alternative namedquery for nativequery

i need to change my query from native-query to (named-query or create-query) in jpa. em = getEntityManager(); String query = "SELECT kcu.table_Name FROM INFORMATION_SCHEMA.key_column_usage kcu,Information_schema.Tables kt " + "WHERE…
jackrobert
  • 131
  • 6
  • 22
0
votes
1 answer

date based querying grails

i have a domain class: class A{ String abc String def Date dateDestruction } I want to write a namedQuery or a closure which would enable me to retrieve the count of various objects of the A, on the basis of month and year given. I want…
Gaurav Sood
  • 157
  • 3
  • 16
0
votes
1 answer

Searching across of 2x entities JPA

I have two entities of JPA, Game and GameScore which are connected. If player join game a new GameScore is made for him. But i need to get Games where is not joined player(does not have GameScore). How I can do that? I tried by NamedQueries and…
0
votes
1 answer

Entity name getting replaced on named query

This is the scenario: I have 2 classes mapped with hibernate: "Foo" and "EnhancedFoo" both classes are mapped to the same table "foo" EnhancedFoo extends Foo Foo.hbm.xml contains a named query "find active foos" which goes like this: from Foo…
RRoman
  • 741
  • 9
  • 19
0
votes
0 answers

Hibernate sql named query with entities

i need to build a sql query that returns a bean with inside an entity... i try to explain me with an example. This is my bean that i want to get from the query: public class EventiPerGiorno { private Eventi evento; // THIS IS AN ENTITY …
Tobia
  • 9,165
  • 28
  • 114
  • 219
0
votes
2 answers

Compile-Error in Boolean-Expression in Named-Query (JPA)

In my project I'm using JPA2 and Hibernate within eclipse Indigo. I have an abstract BaseEntity class which provides some fields that are needed for all entities in my project. Therefore this class is extended by all other entities I use in my…
Stefan
  • 337
  • 6
  • 20
0
votes
1 answer

How do I use Hibernate's findByNamedQuery to return a List of Longs?

I'm using Hibernate's getHibernateTemplate().findByNamedQuery() in order to execute a stored procedure in SQL Server (for optimization reasons). The stored proc is supposed to return a List of Longs. From what I can see, the only way I can return…
0
votes
1 answer

Open JPA how do I get back results from foreign key relations

Good morning. I have been looking all over trying to answer this question. If you have a table that has foreign keys to another table, and you want results from both tables, using basic sql you would do an inner join on the foreign key and you…
SoftwareSavant
  • 9,467
  • 27
  • 121
  • 195
0
votes
0 answers

Hibernate "Invalid column name" error when using a NamedNativeQuery

I have recently changed an object to have a @OneToMany mapping to another object, with the FetchType.LAZY. But when I try to load a list of these objects using a @NamedNativeQuery, which calls an Oracle function, it throws a java.sql.SQLException:…
marktucks
  • 1,771
  • 1
  • 16
  • 21
0
votes
1 answer

Grails named query for NOT IN

Trying to come up with a succinct way to create a named query with NOT IN clause. Restrictions class does not seem to have a "not in" construct. Anyone know a good way to do this? Solution: static namedQueries = { activeOnly { eq…
dbrin
  • 15,525
  • 4
  • 56
  • 83
-1
votes
1 answer

nHibernate named query returns not all results

I have a few simple named queries with only joins, ant couple subselects. All of them ar working perfectly except one. The problem is, that when i run SQL code in Management Studio, i get 177 results, and when i run named query with the same SQL…
JNM
  • 1,175
  • 4
  • 20
  • 39
-1
votes
2 answers

Does Hibernate core 5.3.7.Final is vulnerable in spring boot project for log4j vulnerability?

For our spring boot project , We are using customized spring boot library and it has been upgraded now. But during upgrade we have kept older version of hibernate core 5.3.7.Final to support namedNativeQuery functionality. And this version…
Ganesh Java
  • 37
  • 2
  • 9
-1
votes
1 answer

UPDATE AND REPLACE part or a string/record with parameter

ALL> I have here a named query to update and replace records. @NamedQuery(name = POST.UPDATE_POST_MESSAGE, query = "UPDATE Post p SET p.message = REPLACE(p.message, :value, 'ANONYMOUS')" I wanted the "old string" to be parameterized but it shows an…
overflown
  • 11
  • 4
-1
votes
1 answer

JPA/Hibernate - No query defined for that name

I have looked at all the similiar posts but i just cannot figure it out. Any ideas ? Here is my Main: The Entity itself: and finally my persistence.xml which is located inside META-INF in document root. Annotation processing is turned on inside…
MajesticOl
  • 311
  • 1
  • 20
1 2 3
34
35