Questions tagged [hibernate-native-query]

107 questions
0
votes
2 answers

Hibernate: how to set parameters to createNativeQuery?

I am using following query: public String getAmount(String userId, String companyId) { Integer amountList = entityManager.createNativeQuery("SELECT scan.attorney.Get_Amount(?, ?) AS amount FROM DUAL") .setParameter(1,…
fatherazrael
  • 5,511
  • 16
  • 71
  • 155
0
votes
1 answer

how to call spring jap query none parameters

I use spring data jpa with native query I have already some query like this How to use native query none parameter. String q="SELECT t1.blockNumber-1 FROM someTAble t1 LEFT JOIN someTAble t2 ON t2.blockNumber = t1.blockNumber-1 WHERE…
jjosjoahu
  • 131
  • 7
0
votes
1 answer

How to check missing number in some column

I use Mysql and spring data jpa I Have Questions about how to find missing data some column that column attribute is int. So.if i insert some data in some data column. number table seq | number | sometext | someData | something | some | some when…
jjosjoahu
  • 131
  • 7
0
votes
1 answer

I'm using spring boot, can I enter values in database without using entity classes?

It's not working like this? How to add data? @Override public void addArticle(Article article) { //Add article String sql = "INSERT INTO articles (articleId, title, category) values (?, ?, ?)"; jdbcTemplate.update(sql,…
0
votes
0 answers

Hibernate native query does not create auto incremented primary key

I have a table generated using liquibase as follows
user_mda
  • 18,148
  • 27
  • 82
  • 145
0
votes
1 answer

How to map nested projections with native query

I want to map my query result to RequestProjection interface values. The following code works and return request id and submission date. I need to return worker name too. I have tried r.worker_name AS workerName and r.worker_name AS worker_name and…
0
votes
0 answers

PostgreSQL and Hibernate: On DELETE CASCADE not working

I have a named native query which looks so: @NamedNativeQuery(name = "deleteRecipes", query = "DELETE FROM RECIPE WHERE rcp_acc_identifier IN (?1)") These are the important parts of the recipe table: …
Bevor
  • 8,396
  • 15
  • 77
  • 141
0
votes
1 answer

org.postgresql.util.PSQLException: ERROR: syntax error at or near "." Spring pageable object with sort query

I have a native query with spring pageable @Query(value = "with RECURSIVE tbsons as(select * from customers where id=:companyId union all select customers.* from customers join tbsons on customers.parent_id=tbsons.id) SELECT * FROM tbsons where…
Edayan
  • 537
  • 1
  • 7
  • 17
0
votes
2 answers

Hibernate OGM mapping @Embeddable objects of native query

How can I read list of @Embeddable objects from MongoDB with Hibernate OGM after aggregation. I have entity like this @javax.persistence.Entity public class MySession implements Serializable { @Id @GeneratedValue(strategy =…
0
votes
1 answer

Hibernate query method requires all columns being returned in query?

I have written a native query for a repository method that groups by specific columns. I can't group by id as that will break the grouping. @Query(nativeQuery = true, value = "SELECT description, model_year, take_rate, number " + …
tomaytotomato
  • 3,788
  • 16
  • 64
  • 119
0
votes
1 answer

Multiples statements where clause with differents values in Sql using JPA

Hi guys I´m doing a native query for my project using JPA, but i don´t know how can I do a type of if and else in a where clause, my ?0 can be 4 values: 10,20,30 and 40, when ?0 is 10, 20, 30 I should use CI.QTD <= and when ?0 is 40, the condition…
0
votes
1 answer

Native SQL(written in xml) result set mapping to POJO(annotation based)

I'm working on a Spring MVC legacy project and currently, we are upgrading the spring(2) and hibernate(2) to latest version. Previously in the project there are sql-query and entity mappings are done in the XML files and we are upgrading the entity…
0
votes
1 answer

Spring - native queries mixed with hibernate when columns name are not the same as in the model

I'm trying to make some queries that should return a list of users paged, sorted, etc but since the column names are different than the model properties I can't mix the native queries with hibernate getting an error... Here is my model, controller,…
0
votes
1 answer

MySQL query into Hibernate or Native query for Birthday Notification

I have a User table which have various details related to User like ID, Name, Profession, Email, Mobile, DOB. I want to write query which should fetch users whose birthday is tomorrow. Working MySQL query: SELECT * FROM user WHERE DATE_ADD(DOB,…
0
votes
1 answer

hibernate native query complex constructor mapping

Java, Spring Data JPA I have 2 entities: class Source { Integer id; String name; } class Item { Integer id; String name; Integer sourceId; } I need statistic native query result like this: select s.id source_id, s.name source_name,…