Questions tagged [nativequery]

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

Related links

355 questions
1
vote
2 answers

Use application properties file to pick the table name in a native query?

I am using a native query in my Spring Boot application, and I want to be able to pick the table name from my properties file. I attempted using spel expressions and it does use the table name specified in the @Entity annotation...however I want to…
1
vote
1 answer

org.postgresql.util.PSQLException: ERROR: operator does not exist: date = bytea on date null in native query JPA

I would like to have a native query for Postgresql, however I could not make it work with dates. I can receive date as null, or date as date, so I like to work in both cases: " case when coalesce (?3, null) = ?3 then true " + " else p.start_date =…
vikifor
  • 3,426
  • 4
  • 45
  • 75
1
vote
1 answer

how to get Null records from oracle database if column is Number type and nullable

I have Oracle database table with three columns i.e Id,RTOName,VehicleCode. my table looks like below RTOName is the varchar2 type and VehicleCode is NUMBER(2,0) and is nullable field. So I have the data like below and I want to fetch the records…
1
vote
1 answer

Spring Data native query with params don't work

I have a native query like the following one: @Query(value = "SELECT * FROM (" + " SELECT result.*, ROWNUM rn FROM (" + " SELECT tmp.* FROM (" + " SELECT " + " e.id, " + " …
big_OS
  • 381
  • 7
  • 20
1
vote
1 answer

Getting Null Values in Spring Native Query Project

This is my Data Repository file and i used native query to retrieve all data address(Locations) of Data. I called the function using Postman and I got null outputs of locations. This my first time of using Native query and its really impossible to…
chamikamac
  • 25
  • 6
1
vote
0 answers

Is it possible to dynamic query to stored procedure?

I have a Spring boot application. I need a feature to dynamically query the stored procedure. What I mean by dynamically, @NamedNativeQuery(name = "getCustomFoo", query = "select * from SP_FOO_CUSTOM where id = 1", resultClass = Foo.class) but id…
gfg007
  • 171
  • 8
1
vote
0 answers

Checkmarx - Improper Resource Access Authorization on native query

I am trying to scan java code using checkmarkx. I have a JPA repository with the below method. @Query(value = "select t.* from transactions t, applications a, payment_processors pp " + "where t.paymentProcessorTransactionId = :x " + "and…
saurabh landge
  • 115
  • 1
  • 2
  • 9
1
vote
1 answer

error syntax error at or near ":" for split_part () of createNativeQuery in spring boot for postgresql

I'm getting SQL exception while executing the query which contains split_part() method as split_part(value::TEXT,':', 1). String queryStr = " select split_part(value::TEXT,':', 1) from table"; Query query =…
Saroj
  • 43
  • 4
1
vote
0 answers

Complex SQL query takes 2 seconds on Database, but 80 seconds in Java Application

I have a complex SQL query that joins several tables and calls some function for some data calculation. Even, I've turned it into a View in order to build a comfortable JPA implementation to obtain the data. The base SQL query takes 2 seconds when…
1
vote
1 answer

Spring Boot update field in database hardcoded

i have this in my repository @Transactional @Modifying @Query(value = "UPDATE pengajuan u set u.status_approval ='Komite' where u.id_pengajuan =:idPengajuan", nativeQuery = true) void updateStatusPengajuan(@Param("statusApproval") String…
Ernesto
  • 39
  • 6
1
vote
3 answers

How can I improve the native query for a table with 7 millions rows?

I have the below view(table) in my database(SQL SERVER). I want to retrieve 2 things from this table. The object which has the latest booking date for each Product number. It will return the objects = {0001, 2, 2019-06-06 10:39:58} and {0003, 2,…
Buda Sergiu Flavius
  • 210
  • 1
  • 3
  • 13
1
vote
1 answer

How to map native query result into custom class object?

I have three classes: Lending, LendingReturn and ProductLending. Lending @Entity public class Lending implements Serializable { @Id private Long id; private BigDecimal amount; private Instant createdDate; private User lender; private…
1
vote
1 answer

different result by executing query in console and namedQuery

in my java web application i need to inquire a list of deposits from a view named VwDepositsInfo by customerNumber. when i execute my query: select * from VW_DEPOSIT_INFO v where v.CUSTOMER_NUMBER=:customerNo in database console my resultList size…
Sobhan
  • 1,280
  • 1
  • 18
  • 31
1
vote
2 answers

Adding parameters optionally to Spring Data JPA Native query

I am using Spring Data JPA with native queries like below public interface ItemRepository extends JpaRepository { @Query(value = "select * from items i where i.category = :itemCategory and i.item_code = :itemCode", nativeQuery =…
Meena Chaudhary
  • 9,909
  • 16
  • 60
  • 94
1
vote
1 answer

Hibernate Native Query error

I am getting a strange error when trying to execute a native query in hibernate this is my query: String qsf = "LEFT OUTER JOIN record_v2_record_audit rra ON r.record_id = rra.record_id " + "LEFT OUTER JOIN record_audit ra ON rra.record_audit_id…
travega
  • 8,284
  • 16
  • 63
  • 91