I would like to know how to query some child objects using their name as a parameter in Spring boot. Let’s say I have a class parent with a one-to-many relationship with the child. The child has a parameter called name. So I would like to query using like “%name%” so the query would return m…
Tag: jpa
Showing a specific JSON response for my GET endpoint
I have a many-to-many relationship between Department and Employee I have already done a mapping for the GET endpoint which returns a list of departments that contain Employees, this is the request: http://localhost:8080/api/departments/1/employees, and this is the response I get: This is the code that gets t…
NullPointerException on JPA on SpringBoot
I’m new on SpringBoot and I’m making a small CRUD. When I try to make a GET request that show me a list of soccer teams from my BD called “soccer” I’ve have the following error message: My model “Equipo” is: My Repositorie “EquipoRepo” is My service “…
testEntityManager.persistFlushFind() giving error “detached entity passed to persist”
I was trying to test h2 Repository with spring-boot-testing .Below is the Testing code is used.: In the above code I am facing this “detached entity passed to persist”. “testEntityManager.persistFlushFind(new Product(1,”A”,”dec”,false))” is giving below error: P…
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
Hibernate how to commit transaction even when exception pops up
i have a method in Service A And another method in Service B My problem is that when “repository.insertRandomValue()” throws ConstraintViolationException for example, then even tho it was caught in catch(), the thread ends with I have tried setting the propagation to REQUIRES_NEW and tried to set …
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 ensu…
Problem with Foreign Key in @OneToOne annotation
I have spent a couple of days with a weird problem. There is a plethora of similar posts here in StackOverflow and I have check a lot of them but I was unable to find something similar with this. I have a Human Parent class A User child class : and also a CollectionOfContactMethods with composition relationsh…
Can a Java hibernate/persistence entity have a related entity ID as well as the related entity?
Pretty simple setup, I have a building entity that belongs to an account. So the building entity looks like: (BaseEntity provides id, created and lastModified columns) I.e. The building has a name, the ID of the account it belongs to, and then the account entity that it belongs to. However, with this setup I&…
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; nes…