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

avoiding multiple selects when using kew word "new" in hql

I have the following code in java. List users=List)session.getNamedQuery("PkUser.loadHelperUsers").list();, I think it does not matter what the "UserHelper" class is that's why I do not write it, not to overload my…
0
votes
1 answer

Hibernate namedquery error-parameter id does not exist as a named parameter in [from Employeenam e where e.name=:name]

I have two classes,a POJO and a main class and i'm working with named query with annotation in hibernate. the POJO class is as follows @NamedQueries( { @NamedQuery( name="findEmployeeName", …
Ezhil
  • 261
  • 2
  • 10
  • 31
0
votes
2 answers

I have a issue in hibernate namedquery

I'm using annotation for named query in hibernate.I have two classes a POJO class and a main class.The POJO class is as follows @NamedQuery( name="findEmployeeName", query="select * from employee " ) @Entity @Table(name="employee") public…
Ezhil
  • 261
  • 2
  • 10
  • 31
0
votes
1 answer

javax.persistence NamedQuery not working as expected

I'm probably being dense about this but a query isn't returning the results I'm expecting... I have two tables(entities): Properties and Landlords as follows: Properties is made up of the fields (amongst others): Id, propertyRef and landLordsid…
0
votes
1 answer

DATE_SUB named query MYSQL

Have a named query written like this select u from User u where u.creationdate < DATE_SUB(CURDATE(),INTERVAL :upperDate DAY) and status=:status and reminder_counter =:counter But I get a Syntax error parsing. Any ideas`? P
hynespm
  • 641
  • 4
  • 17
0
votes
3 answers

Hibernate Named Query with Aggregate function

I am trying to execute a named query in Hibernate. The query is defined in this mapping file:
cowls
  • 24,013
  • 8
  • 48
  • 78
0
votes
2 answers

Illegal conversion exception after passing Enum List to namedQuery.setParameter() in Hibernate

I am using Hibernate over DB2. When I create a NameQuery with the parameter being a List of enum values, getResultList() throws Illegal converation exception. @NamedQuery( name="Deliverable.deliverableFiles", query="Select distinct f…
Hank
  • 121
  • 1
  • 8
0
votes
1 answer

org.hibernate.QueryException: Expected positional parameter

I have a namedQuery thru which I pass 2 parameters like below, ArrayList idName= new ArrayList(); idName.add(id); --int idName.add(ABC); --String and I pass this object to namedQuery as follows: return…
Geek
  • 3,187
  • 15
  • 70
  • 115
0
votes
2 answers

hibernate namedQuery

I want to pass values to a NamedQuery. I am selecting from a view and my namedQuery in xml file looks like this:
Geek
  • 3,187
  • 15
  • 70
  • 115
0
votes
1 answer

How to determine if an Entity has a NamedQuery

Again, posting and answering a question for the benefit of others based on a problem I had the other day. Hopefully this saves someone a bit of time. I was a little surprised this wasn't built into JPA's EntityManager. How can I determine if an…
Snekse
  • 15,474
  • 10
  • 62
  • 77
0
votes
2 answers

Hibernate NamedQuery with a condition on inner List

class A{ // one to many mapping List listOfB; //getter and setter; class B { String s; //getter and setter } Now, when I get class A , it will return all the associated class Bs in listOfB. But I need certain…
Priyank Doshi
  • 12,895
  • 18
  • 59
  • 82
0
votes
1 answer

Polymorphic query with JPA and mapped superclass to return count of a particular concrete entity

I have a BaseEntity abstract class which is a super class for all my entities. This is a MappedSuperClass. Now I want to define a named query preferably on the base-entity such that it returns me the count of a specific sub class entity. So for e.g…
Vishal
  • 1,169
  • 2
  • 12
  • 20
0
votes
0 answers

NamedQuery gives an error

Possible Duplicate: How to write NamedQuery haversine formula in NamedQuery? I want to run below namedquery: List result= em.createQuery("select sum(u.mlatitude) from UserGpsLocation u").getResultList(); return result.get(0); Can anyone…
user1522804
  • 149
  • 2
  • 11
0
votes
1 answer

JPA @NamedNativeQuery sql with dynamic orderby and column name

This is my NamedNativeQuery: SELECT * FROM ( SELECT ROWNUMBER() OVER(ORDER BY CMSSCODE DESC) AS EL_ROWNM , CMSSCODE , CMSSDESC FROM tableName d WHERE CMSPCODE = ? ) a WHERE a.EL_ROWNM < ? and a.EL_ROWNM > ? I need to create in a dynamic way the…
user590586
  • 2,960
  • 16
  • 63
  • 96
0
votes
1 answer

In Java, are @NamedQueries that are changed available right away, or is there a caching issue in Hibernate?

In Java, are @NamedQueries that are changed available right away, or is there a caching issue in Hibernate? @NamedQueries( { @NamedQuery(name = etc.. I made changes to 2 @NamedQuery but they are not doing what they should. Does Hibernate need…
JoJo
  • 4,643
  • 9
  • 42
  • 65