Questions tagged [nativequery]

JPA concept that allows queries in your native database syntax (instead of JPQL)

Related links

355 questions
2
votes
0 answers

Get ElementCollection with native query

I have this entity that i need to join with another unrelated entity, this is why I am using a native query. @Entity @Table(name = "surveillance_questionnaires") @Setter @Getter public class SurveillanceQuestionnaire { @Id …
T. Aris
  • 31
  • 1
  • 5
2
votes
1 answer

SpringDataJPA - What does '?1' in the where clause mean in the below query?

@Query(value="select * from author a where a.last_name= ?1",nativeQuery = true) What does ?1 mean in the above query?
2
votes
0 answers

Spring JPA show sql - Is the query printed before or after executing

We are facing an issue with an API that is consuming a bit of time. In the log, it's showing the delay with a query. [INFO ] 2022-06-01 13:38:51.122 (DataBuilder.java:294) [DEBUG] 2022-06-01 13:38:52.927 (SqlStatementLogger.java:128)…
Arun Sudhakaran
  • 2,167
  • 4
  • 27
  • 52
2
votes
0 answers

JDBC Driver - how to pass null datetime2 value as parameter to native query?

After updating from JTDS to MSSQL JDBC driver (version 10.2.0.jre8 - hibernate 4.3.11.Final) I'm encountering the following error when trying to pass a null value within a datetime2 parameter used within a native query: Root Exception stack…
LisekKL
  • 131
  • 2
  • 12
2
votes
1 answer

JPA Repository nativeQuery with pageable, join table not working when pageable.size = 1

I have this sql query that works fine SELECT ppd.userId, AVG(Coalesce(sm.score, 0)) AS avgScore FROM Table1 ppd LEFT JOIN Table2 sm ON ppd.userId = sm.userId AND sm.created BETWEEN start AND end WHERE ppd.someId IN (listOfIds) …
Zhmel
  • 71
  • 7
2
votes
0 answers

Spring JPA Data : Query on ElementCollection

I have the following class called "UserInterest". It follows the following definition: @Table(name = "user_interests") public class UserInterest { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_interest_pk_generator") …
Mamun
  • 375
  • 2
  • 8
  • 17
2
votes
3 answers

Problems with native query spring data JPA returns empty JSON array with empty objects

I'm learning spring 5 MVC with spring data JPA and sql queries I'm trying to use a native query in my spring api restful example but when I run the project, my method returns an empty json object. My Model class @Entity @Table(name =…
Kuroi
  • 63
  • 7
2
votes
1 answer

How to pass operators like "<",">","=" (less than,greater than,equals to) as parameters to a native query in springboot?

For example let my query be as shown below: String query="select * from table_name where column_name1 > ?1 and column_name2 < ?2"; @Query(value = query, nativeQuery = true) public List getResult(String filterValue1,Integer…
2
votes
1 answer

Mapping JPA Entity with result of native query

I'm using Spring Data JPA to map entities and tables. In my PostgreSQL DB, I have a table called declared_location, that stores locations with long and lat. I wrote a sql native query with postgre specific syntax in order to retrieve a list of…
2
votes
1 answer

How to execute a postgresql json function query in jpa nativequery?

Here i am trying to fetch an object named business from my jsonb column case_data where case_id is set through parameter. @Query(value="Select case_data->'business' from onboarding_cases where case_id=?1",nativeQuery=true) List
2
votes
1 answer

'select count(*) from' is replaced by 'select count(where)' in spring jpa native query when using pagination

I am using a native query in JPA repository inside @Query annotation @Query(value = " select * from message where id in(select if(coalesce(a.maxId,0)>coalesce(b.maxId,0), a.maxId, b.maxId) maxId from (select from_number, to_number, " + …
Anas
  • 173
  • 1
  • 4
  • 20
2
votes
1 answer

Postgres Exception ERROR: syntax error at or near ":" Position: 46

I'm getting SQL exception while executing the below query. @Query(value="SELECT * FROM lat_long WHERE ST_DWithin(geom :: geography,ST_SetSRID(ST_MakePoint(:lat, :lang),4326) ::…
prachi
  • 113
  • 1
  • 8
2
votes
0 answers

pagination and naive query + eclipse link

I am trying to write a native query and pagination in eclipse link + JPA for PostgreSQL but I'm getting exceptions : Here is the code what I tried : @Query(nativeQuery = true, value= "select a.* from rqst a LEFT OUTER JOIN table_b b ON a.id= b.id…
Developer
  • 2,389
  • 4
  • 11
  • 17
2
votes
1 answer

Parameter with that position [1] did not exist error when using Spring Data native query

I am new to spring boot and spring data jpa. I am trying to use native queries for executing search based on search attributes received from UI. The records that are obtained based on the searchParam should search if the searchParam is contained in…
svijay.aug12
  • 531
  • 3
  • 13
  • 32
2
votes
0 answers

Hibernate transaction does not commit changes to database (SQL Server)

We have a function in our application that cleans up the database and resets the data, we call a method cleanup() which at first deletes all the data from the database and then calls a sql script file to insert all the necessary default data of our…
Shahe
  • 964
  • 2
  • 13
  • 34