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
1 answer

NHibernate - How to log Named Parameterised Query with parameter values?

I have a parameterised named Query like this : Query moveOutQuery = session.createSQLQuery(moveOutQueryStr.toString()) .addEntity(MyClass.class) .setParameter("assignmentStatus", Constants.CHECKED_OUT) I want to see…
Zafar Nasim
  • 529
  • 1
  • 6
  • 10
2
votes
2 answers

h2 Database performance issues with Named Query

Just some pre-information. We are using a H2 File Database which is already around 15 GB. Our Application runs on Windows Clients Jetty Webserver H2 File Database Every time Data needs to be updated on client side, the user will get a zip File…
kism3t
  • 1,343
  • 1
  • 14
  • 33
2
votes
2 answers

Multiple dynamic parameters to search with Spring Boot, sometimes someparam can be empty

I am working on Angular 2 with a Spring Boot application, and I am passing some search parameters through my UI to SpringBoot RestController where I am using the CrudRepository interface for CRUD operations and am using some methods like…
rahul sharma
  • 101
  • 4
  • 10
2
votes
1 answer

how to use a stored procedure in nhibernate

Hello I try to use stored procedure in nhibernate and I found some methods : exec CO_Visites_Treeview_Sel…
P. Sohm
  • 2,842
  • 2
  • 44
  • 77
2
votes
1 answer

JPA named query with group by with paramnames and values

I am new to Hibernate and I need to write a JPA named query on my entity using Group by. So this is what my entity looks like: @Entity @NamedQueries({ @NamedQuery(name="Transaction.getByYear", query="from Transaction where…
Shravan DG
  • 527
  • 1
  • 5
  • 16
2
votes
2 answers

Using if else statement for named query?

@NamedQueries( { @NamedQuery(name = "GetAvailableProducts", query = new StringBuilder("").append("SELECT p FROM Product p WHERE p.type= :type AND (p.available = 'ALL' OR").append(isTest() ? "(p.available = 'TEST' OR)" : "…
kamaci
  • 72,915
  • 69
  • 228
  • 366
2
votes
1 answer

How can I convert this 3 JOIN query into a Spring Data JPA named query method?

I am not so into Spring Data JPA and I have the following problem trying to implement a named query (the query defined by the method name). I have these 3 entity classes: @Entity @Table(name = "room_tipology") public class RoomTipology implements…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
2
votes
2 answers

Access method in controller from view

I have this code in my view to display a input box and a submit button. (UPDATED)
As I click…
Kendall H.
  • 461
  • 3
  • 9
  • 21
2
votes
0 answers

What would be the Named Query for Following sql statement? I am using hibernate JPA

What would be the Named Query for Following sql statement? I am using hibernate JPA Select f.FUND_MGMT_CO_CD, f.FUND_CD, S.HOLDING_EN_NAME, S.HOLDING_FR_NAME, c.FUND_MKT_TRAX_CD, T.PORTFOLIO_DT, T.SEC_PCT from IPD_FUND_T f inner join…
Mohit Singh
  • 5,977
  • 2
  • 24
  • 25
2
votes
3 answers

PropertyNotFoundException: Could not find setter for column_name on class

I am facing the with hibernates named query and transform to bean. Here is the code: query = session.getNamedQuery( "LAST_ADDED_DOC" ); query.setString( "module", inNpUploads.getModuleName() ); query.setString( "mapping", inNpUploads.getMappingId()…
Mohammad Faisal
  • 5,783
  • 15
  • 70
  • 117
2
votes
0 answers

How to refer on a foreign key value using JPQL?

I got two tables. Table_A and Table_B. Table_B has the foreignkey table_a_fk. What I'm trying to do is the following: "Give me everything from Table_B where the id(PK) of Table_A is like table_a_fk of Table_B " In MYSQL it's not that hard. I wrote: …
Melle
  • 23
  • 5
2
votes
1 answer

HQL fails on joining two tables on a common foreign key column

I have two entities @Entity @Table(name="one") public class One implements Serializable { @Id @NotNull @Column(name = "id") private String id; @Column(name = "name") private String name; @Column(name = "title") …
Annapoorni D
  • 831
  • 2
  • 13
  • 30
2
votes
1 answer

org.hibernate.hql.ast.QuerySyntaxException: unexpected token:

My HQL : "from UserLocation where user.username =:username and timestamp > NOW() - INTERVAL :timeOffSet MINUTE"; I am getting following error: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: : near line 1, column 101 [from…
Amit Kumar
  • 2,685
  • 2
  • 37
  • 72
2
votes
1 answer

Hibernate : How to get Named SQL Query resultset as List instead of List

I wrote a named sql query in hibernate mapping file which return only few columns from different tables.
2
votes
0 answers

Hibernate subselect fetching of association, how to pass parameters?

We have a class A that has two levels of nested associations as follows: @Entity @NamedQuery("select a from A JOIN FETCH b"); public class A { @OneToOne(cascade = CascadeType.ALL, optional = true) @JoinColumn(name = "XXX") private…
Paddy
  • 3,472
  • 5
  • 29
  • 48