I’m using Hibernate Envers in Spring Boot application with Spring Data. For example, I have a base class And class I need to audit only actions that were done and the timestamp of them. For example, when I create new Entity or update existing Entity object, I want auditing table to contain the following information: id of entity, time of
Tag: spring-data-jpa
Problem in updating the entity with unidirectional @ManyToOne relation
I have two entities as below and the main problem is when I want to update the AccountRequestStatus entity. I save the integer enum code of AccountRequestStatusEnum in the database to persist the AcountRequest status in the whole application. AccountRequestStatusEnum AccountRequest AccountRequestStatus The first time that an account request comes from MQ my to application, I save the initial code
Update DB column which has null value in Spring boot JPA
I am trying to update in the database with the help of the Spring JPA and having an issue while doing it. I have an Embedded class in my entity. My entity class is : My Repository class is : Audit, Transfer and Beneficiary Details are my Emededded class and those are : My Controller class is: My error stack
Spring Boot Hibernate creates tables with wrong names
When I run my project, the Hibernate creates automatically tables with wrong names. I have two tables User and Role and also three classes: abstract class IdField.java: User.java class: and Role.java class: And Hibernate creates two tables with wrong names as id_field and id_field_roles: but I want table names as it is in @Table annotation like “user” and “role” Answer
How to create a JPA entity for a table that doesn’t have a Primary Key or Unique Key column
l have a table without a Primary Key or Unique Key column. I need to manipulate this table from the Spring application by using JPA and Hibernate. While I was trying to map this table’s entity, it fails because there’s no @Id mapping. I tried to make a composite id from all the entity properties to ensure uniqueness, but in
How can I show Multiple Rows in JSON
I need to show sql result in a JSON like this in a spring boot app. Class Repo Service Controller I’m getting this message on log: query did not return a unique result: 94; nested exception is >javax.persistence.NonUniqueResultException: query did not return a unique result: 94 After that, I wanna delete/update all of salesperson associated id’s (transfer clients (id’s) from
JPA repository return one item from db but there are multiple item in the db
I have the following function in my repository When I use this function in the controller I got back one User. For example, if I have a String “John” and I call the repo function with that string I got back “John Doe” but I also have “John Doe Jr” in the db and I need him too. Why I
Spring Boot 2 Multiple Datasource – work only the one with @Primay annotation
I have a problem, I’m trying to use two Oracle databases in spring boot using DataSource, The DataSource wiht the @Primay annotation works fine but the oher one only gives me: I don’t have idea what I should do now. Any help will be welcomed. Thanks! application.properties pom.xml DatabaseConfiguration.java Repository from 1st DB Repository from 2nd DB Answer I could
Spring Data JPA sorting by property without hardcoding
I have entity that has several fields: I want to have code which is capable to sort by foo and sort by bar depending on the request. I know that there is tool that could be used like this: But it seems like this approach is not perfect because field names are hardcoded and in the case that some field
Using the concept of JPA, how to update table using data from another table?
FmoReorgGeo.java FMOReorgGeoServiceImpl.java FMOReorgGeoRepository.java ERROR LOG *I am trying to fetch data from reorgViewX and then updating FmoReorgGeo table. I am being able to fetch data correctly but when running update query I am getting error. The error says: Could not extract result set metadata; nested exception is org.hibernate.HibernateException: Could not extract result set metadata. I am using the concept of