Questions tagged [nativequery]

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

Related links

355 questions
1
vote
0 answers

Query timeout in JPA for update

I'm updating table using jpa (native query). I want to set timeout for the update query to run. I tried using query.setHint("javax.persistence.query.timeout", timeout), but it doesn't work. Is there any other way to add timeout ? Below is the code…
1
vote
1 answer

Please help converting this SQL to JPQL, problem with subquery (EclipseLink v2)

I have days trying to solve this. I need to have an ORDER BY and a LIMIT in a subquery, this is the native SQL: SELECT ope.idOperacion AS OperationID, est.nombre AS LastStatusName FROM SSCM_4.Operaciones4 ope INNER JOIN…
Xavier Callejas
  • 131
  • 2
  • 11
1
vote
0 answers

JPA native query not working when called in production

I am writing a school project where people can buy cinema tickets. I want to be able to send the users free cinema tickets for certain occasions that are only valid for a certain day. I run a CRON job at midnight that will set the tickets to…
L.Butz
  • 2,466
  • 25
  • 44
1
vote
2 answers

How to pass limit and off set values dynamically in native query

I'm using native query to fetch the pagination results from PostgreSQL and I used this query and I'm getting the below exception: SELECT a.* FROM table1 a LEFT OUTER JOIN table2 b ON a.clmn1 = b.clmn1 WHERE (a.clmn3 = ?3 OR a.clmn4 ISNULL) …
user2108383
  • 239
  • 1
  • 9
  • 22
1
vote
0 answers

Cache JPA Native Query

PROBLEM: Need to cache a native query (Hibernate Query Caching) in a stateless DAO EJB. Hibernate 5.3, Jpa 2.1, JavaEE 7. RESEARCH: Working example: getEntityManager().createNativeQuery("SELECT MIN(start_date) FROM report") …
Zon
  • 18,610
  • 7
  • 91
  • 99
1
vote
2 answers

How to pass in SQLServerDataTable object to JPA native query

I am trying to pass in a SQLServerDataTable as a Parameter to a JPA native Query. @Query(value = "Select u FROM #{#entityName} u with (nolock) INNER JOIN :listTable pt on pt.PhoneNumber = #{#entityName}.PhoneNumber WHERE EntityType = :entityType",…
Brian Antao
  • 131
  • 2
  • 11
1
vote
1 answer

Not able to get array object response in @Query annotation in Spring

My Repository @Repository public interface TestNativeQRepository extends CrudRepository { @Query( value="SELECT qplt.name price_list_name, qplab.status_code, qplab.start_date, (SELECT charge_definition_code FROM…
Manoj Kumar
  • 139
  • 1
  • 3
  • 12
1
vote
1 answer

Update password in Spring Boot Thymeleaf

I want to update my password via Thymeleaf. So far, everything works except as soon as I call my update method I get an error message. This is my code: @PostMapping public String updateOldPassword(@Valid @ModelAttribute("password")…
Bernd
  • 593
  • 2
  • 8
  • 31
1
vote
1 answer

Default Spring Data query with containing "id" in List (JpaRepository)

I have the simple entities as follows: Suggestion.java: @Entity public class Suggestion { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @OneToOne private Employee author; @OneToMany …
plkpiotr
  • 345
  • 2
  • 9
  • 23
1
vote
0 answers

converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap]

I am developing Spring Data JPA example. In this example I am doing RIGHT OUTER JOIN using native Query as two DB dont have any relations to each other. I am using below native query: @Query(value = "SELECT m.ACC_NUM, m.CUSTOMER_ID AS CID,…
Jeff Cook
  • 7,956
  • 36
  • 115
  • 186
1
vote
0 answers

Hibernate Spring Data native query not able to UPDATE set NULL with MERGE INTO

First of all, I have a working query for MERGE INTO if I directly run it on database. I want to SET NULL to some columns with MERGE INTO WHEN MATCHED THEN part. It simply doesn't work when I use it with Hibernate. This is how my method looks like…
Hon Lun Chan
  • 148
  • 2
  • 16
1
vote
1 answer

Get inserted Id from NativeQuery Hibernate 5.2+

I am using the following code to run native sql queries on hibernate (SQLQuery) has been deprecated. private static int executeUpdate(String sql) { int result = 0; Session session = HibernateSessionFactory.getSession(); …
1
vote
1 answer

Hibernate not updating values through a native query

Dear stackoverflow community, I am not sure why the code below does not update my database data, however taking the query from the hibernate logs seems to work... I am using Hibernate 5.2.12.Final This is my whole function: EntityManager em =…
masber
  • 2,875
  • 7
  • 29
  • 49
1
vote
1 answer

Native Query Like Format Issue in SpringBoot

I am trying to use like operator in native query as below: @Query(value = "SELECT max(id) FROM EMP where id like ___:country%", nativeQuery=true) country as input parameter for method. getting the below…
Rajeswari Reddy
  • 193
  • 1
  • 6
  • 24
1
vote
1 answer

JPQL and Native Query are executed in different order

I am currently working on a project that uses Java, Oracle, and Hibernate. A lot of our legacy code uses native queries to fetch and update our database records, but we've been slowly transitioning to using JPQL. I suspect that the mixing of the two…