I have an TimelineEntity entity, that uses HoTimelineType enum with custom integer value. That custom integer value is stored in the database. Implemented via Using @PostLoad and @PrePersist Annotations Sprint JPA Repository is used to save and get entities. Here is the issue: When the newTE entity is saved, prePersist is invoked, and inside this method, the hoTimelineType is null
Tag: spring-data-jpa
Spring Data Jpa: persisting child entities from parent entity does not update child identity
Environment: OS: Ubuntu 20.04 LTS Java: OpenJDK 17.0.3 Spring Boot: 2.6.7 MySQL: 8.0.29 Is it normal for Spring Data Jpa (or Jpa in general) to NOT update child identity attributes when the child is persisted (saved) via the parent entity repository? Consider this: When I call someClassFunction() I get: The database assigned id is NOT available to me immediately. I
How to retrieve ONE column from another table with Foreign key using Hibernate / JPA
I would like to use the Foreign key “MODEL_ID” to retrieve just one column “MODEL_NAME” from the TT_CARS table, I tried the following code, that works but it returns the whole CARS object. Also I tried the code below, its also not working Is there other way to retieve just the column (MODEL_NAME) using hibernate and JPA?? remarks: The modelName
how do i save a new student that contains entities, but don’t create these entities because they already exist in the database?
I want to save a student and a student has a TargetAudience object as an attribute. These target audiences are allready hardcoded in my database. (targetaudience = campus + major). Now when i post like this: it doesnt work because everythime it creates a new object for the campus and because i use name as a primary key it throws
How can I use more then one param in a spring boot rest Controller?
I want to achive the follwing URL to access my data with 2 params: http://localhost:8080/contactnote?entryDate=2022-02-01?contactType=T Both mappings with a single param is working: But when I try to combine them with two params it wont work, not one of them is usable. My reposiitory looks like this: Answer the URL you entered is invalid, double ?, you have to use
JPA performance – SELECT DISTINCT and/or Java Set
I have a Spring Boot application with a JpaRepository. I am trying right now to obtain all the unique values for a certain field in my db. Let’s suppose I have an object Foo with an Integer PK id and a non-unique Integer field bar. I want to get all the unique values for bar and I’m wondering which query
How to map a table in Spring Data JPA that has 2 columns referencing the same table
I have a table that has 2 fields (pseudonymProfile and realProfile) that both join to the same table. When I try to do the mapping as shown below, I run into an error because the 2 fields use the same name (profile_id) in their @JoinColumn annotation. I’m under the impression that when defining a join column, I need to specify
Combine JPA Query annotation with Oracle sample method
i am trying to pass a parameter into a JPA query Example code But i get an error because of the sample(:percentile). If i just hardcode a number in there it works but not with a param. Is there a way to escape the brackets or something similar? Thx Answer The error is on the following part Unfortunately it does
How Spring Batch Step chunkSize and JpaPagingItemReader pageSize work together
Im developing a Spring Batch application. Although I’m getting more and more comfortable with it, I came across with something that is making me very confused. Please take a look at this step configuration. As you can see it’s a pretty standard step. My confusion is related to the chunk size (50) and the reader (processNonExportedMbfsOperationsItemReader). Reader code next: The
Spring Data JPA: What is wrong or how to correct this jpql query
The entity relationships are – A student belongs to one college And a college can have multiple students. So there is ManyToOne relationship between Student –> College And a OneToMany relationship between College –> Student. The entities are as below. and 1) I am using the below jpql query in spring data jpa repository. I am expecting that a list