Questions tagged [hibernate-native-query]
107 questions
0
votes
0 answers
wht settings do JPA orm xml named-query
// application.yml
spring:
jpa:
mapping-resources:
- META-INF/mapper/ormMember.xml
// resources/META-INF/mapper/ormMember.xml

dseoki
- 1
0
votes
0 answers
How to pass the Timestamp in GetMapping
Im trying to fetch the data from DB which is updated from todays date to last 30days updated data(Timestamp)
Controller-class
@GetMapping("/getcodeByTs/createdTs")
public List getCodeSetByCreatedTs(@RequestBody Timestamp createdTs){
…

Rajesh
- 1
0
votes
1 answer
jpa postgresql No Dialect mapping for JDBC type: 1111
My Spring boot 2.7.5 app with PostgreSQL gives back an error when I try to run a nativeQuery:
@Query(value = """select import, export from
(select cast(max(sd.value) - min(sd.value) as float8)
from solar_data sd
…

zamek 42
- 793
- 1
- 9
- 15
0
votes
0 answers
How to set limit for accessing data in heidisql?
By default, limit of accessing data in Heidi SQL is upto 100000.
SELECT * FROM tablename WHERE columnname='value' and 'column_name'='value';

Akhilesh Dhiman
- 15
- 7
0
votes
0 answers
How to pass multiple values in a native query and retrieve that data in a Map>?
Here I want to pass a list of Ids and date as a parameter to the database query and I want the query to return data in a Map so the key is the id and List is the data against that id.
Query query =…
user19078589
0
votes
1 answer
Spring native query with GROUP BY and ORDER BY also pagination
What if I have my native query (with PostgreSQL) in a more "complex" way, which I need to GROUP the data in order to apply an ORDER BY clause? Well, doing so with native query (as explained here) the ORDER BY attributes are placed at the end of the…

wmrodrigues
- 483
- 1
- 3
- 10
0
votes
1 answer
How to write jpa method from sql query?
How to write the below query as jpa method using findBy...?
SELECT * FROM user WHERE (user_id=1) AND ('2022-03-04' BETWEEN from_date AND to_date) OR ('2022-03-10' BETWEEN from_date AND to_date);
user16514999
0
votes
1 answer
How to use the query dynamically in spring boot repository using @Query?
How to use the below query dynamically in spring boot repository using
@Query(value="SELECT * FROM do_not_track WHERE (user_id=7 ) AND ('2022-06-25' BETWEEN from_date AND to_date) OR ('2022-06-30' BETWEEN from_date AND to_date)",nativeQuery =…

Rose
- 666
- 6
- 14
0
votes
1 answer
Query with 3 tables in native sql with hibernate
I have 3 tables related with their FK and I trying to do a native query selecting entities joined. I did with 2 tables joined and it worked, but it does not work with 3.
This is my generic method for it
public List

Asturies
- 1
- 2
0
votes
1 answer
Java methods does return an object different from its declaration
I have a java method that returns an Optional:
Optional findOptionalRelation(String a, String b)
In the implementation there is a nativeQuery that counts results in a database:
hqlBuilder.append("SELECT count(r.id)");
…

Rodrigo Doe
- 71
- 6
0
votes
2 answers
JPA/Hibernate: Named Query vs Native Query | Which one to use?
There is native query written by developer
String sql = "Select * from TERP_META where id=" + id + " and type='KCH' ORDER BY ID ASC";
return entityManagerMaster.createNativeQuery(sql, TerpStatus.class).getResultList();
We can also write Named query…

fatherazrael
- 5,511
- 16
- 71
- 155
0
votes
1 answer
Can I map a new column created from my custom SQL query to entity class field?
I have a requirement where I am adding new column from a select query like this:
select
sy.FIRST_NAME || sy.LAST_NAME as full_name,
e.*
from
employee e
left join
USERS sy on sy.SY_USER_ID = act.SY_USER_ID;
I have all the…

Nava1119
- 13
- 1
- 6
0
votes
0 answers
@NamedNativeQuery @SqlResultSetMapping wrong mapping COUNT(*)
I'm having a strange error using @SqlResultSetMapping and @NamedNativeQuery.
My Entity has:
@NamedNativeQuery(
name = "example_query",
query = "SELECT table_A.id, " +
"COUNT(*) AS numberOfA " +
"FROM…

Ed-Genesis
- 117
- 1
- 6
0
votes
1 answer
Error with Spring Data JPA nativeQuery String search
please help.
When I input searchString = "abc" then it works.
But when I input searchString = "a", then it shows the followed error:
java.sql.SQLSyntaxErrorException: Unknown column 'q' in 'field list'
at…

Van Thuan Luong
- 1
- 3
0
votes
1 answer
Sonar Qube Issue: Remove this forbidden call: Native Queries
enter image description here
public String getVersion() {
return (String) em.createNativeQuery("SELECT pkg_deploy.get_current_build FROM dual").getSingleResult();
}
The Sonar complain about not using native queries. In this…

Klajdi
- 1