111 questions
0 votes
1 answer
38 views
Hibernate 5 native query maps wrong values to columns
Hibernate 5.6.15.Final I have 2 entities with 1-to-1 relationship, both have audit fields "createdBy", "modifiedBy", "createdDate", "modifiedDate". class ...
3 votes
3 answers
262 views
How to use JPA @Query with a native SQL query to get random results in Spring Data JPA?
I'm developing a Spring Boot application with Spring Data JPA, and I need to implement a repository method that fetches a random selection of questions from a Question table, filtered by a specific ...
0 votes
1 answer
259 views
Reading jsonb from Hibernate 6 native query
The following code behaves differently between Hibernate 6.1 and 6.4 on postgresql: var rows = session .createNativeQuery("SELECT CAST('[1,2,3]' as jsonb) as data, 2 as id", Object[]....
1 vote
1 answer
124 views
How to select all row and give boolean mark the row with max value of a column (with multiple marking)? (Java Native Query, Psql)
Currently I am working on giving a label to my data. I will give the label to data that marked as highest on the resulting query. the problem is the label is not only for 1 case but multiple, and also ...
0 votes
0 answers
183 views
How convert bytea to smallint in postgres native query
i try to use native query and i get above error: column "code" is of type smallint but expression is of type bytea, does anyone know how to fix it? i tried to use CAST to numeric but it ...
6 votes
0 answers
262 views
How to retrieve json column with a native query with projection?
I have a database with a table that contains a column of type JSON. Retrieving all data from the table using the whole entity work without problems. But in a case when I use a native query with some ...
1 vote
0 answers
336 views
Spring data native query filtering by List<String>
Given: Interface projection model with String getType(); Postgres 13; Hibernate+JPA+Spring data; Query filter: " where ... " + " and (COALESCE(:types) is null or model.type in (:...
2 votes
1 answer
2k views
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?