I have these entities: My HeroService is like this: I am using postman to create a new Hero and this is a sample POST request: Although a hero is created and two entities on HeroSkill table are also created, the HeroSkill hero_id column is null, so my new heroes are not associated with their skills as they should be. It
Tag: hibernate
How to disable the Hypersistence banner when using hibernate-types-52 in Spring Boot?
I use the com.vladmihalcea:hibernate-types-52 dependency in my Spring Boot Project. And, I notice that on application boot, some large log messages were added: The hint is nice and the project sounds actually interesting, but still want to have the banner removed from my application. Answer There is a description by the Project Owner why the banner was introduced, why it
graphql-spqr with Spring Boot and Transactional Boundary
We are using graphql-spqr and graphql-spqr-spring-boot-starter for a new project (With Spring DataJPA, hibernate and so on). We have a mutation like this: This mutation works fine: I have ommitted the variables as they are not important. It does not work if I change it to: I get a LazyInitalizationException and I know why: The homeTeam is referenced by an
The increment size of the sequence is set to [50] in the entity mapping while the associated database sequence increment size is [1]
I’m following the Learn Spring 5 etc on udemy and I’m at the part where we test our application. Everything worked fine till now, i was able to connect to the postgreSQL database and all but now I’m stuck at this test failing since 2 days. I don’t understand what is causing the Test to fail. The application run but
spring.jpa.properties.hibernate.jdbc.time_zone applied on writes but not on reads?
I’m using: spring boot 2.0.4.RELEASE spring-data-jpa 2.0.9.RELEASE hibernate-core 5.2.17.Final hibernate-jpa-2.1-api 1.0.0.Final postgres jdbc driver 42.2.9 I have the following entity: and the following property set in application.yaml: Regardless of what the JVM timezone/default timezone is, I want to save and return timestamps in UTC. For testing purposes, I have set the timezone of my application code to US/Hawaii: When I
Why has javax.persistence-api been replaced by jakarta.persistence-api in spring data jpa starter?
I’ve recently started to learn spring boot, data jpa. As I can see from this, the spring boot data jpa starter uses jakarta.persistence-api instead of javax.persistence-api: What is the differences between jakarta.persistence-api and javax.persistence-api? What is the reason of this replacement? Answer From Java Persistence API on Wikipedia: The Java Persistence API (JPA), in 2019 renamed to Jakarta Persistence, is
HQL Hibernate query search check if list contains all elements of another list
I came across a problem that I cannot think of a solution. So I got this piece of code: The problem with this piece of code is that when someone searches with more than one tag (for example: #video, #image), it returns both posts with two tags and one tag. I would like it to return a post with both
Multi-tenant hibernate doesn’t switch between tenants
I am in the middle of changing my spring + hibernate + mysql setup to be multi-tenant. First of all, I have the following in my application.properties: I am not sure if I’m supposed to make it connect to a specific schema here (test) after introducing multi-tenancy? It doesn’t make sense to me, as it’s supposed to use a default
How to store JSON file as a JSON datatype in mysql using Hibernate / Spring boot?
I’ve tried several ways of storing a json file in a database but it ends up creating different columns for each entry. I want to store it as a “json” type in a single column. Is it possible? My json file. users.json It’s a spring-boot application and I’ve the relevant controllers and services. In my domain package. (Address and Company
JPA – Adding and Removing elements in List with ElementCollection
I keep a list of Strings in SQL as @ElementCollection, my main usage is similar to a Queue: fetch it from the database run some calculations remove the first element and insert a new element to the end of the list: this.measurements.remove(0); this.measurements.add(measurement); save it to the database The problem with the current implementation is that removing the first element