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 sh…
Tag: jpa
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…
Where condition not working on related entity
I’m trying to apply the where condition on the related entity, but the result set contains all the related entity data. It appears like the filter is ignored. I have the following entities: Entity …
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 …
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 pr…
How to use Criteria in JPA in Spring boot?
I am using JPA and spring boot. I am new to JPA. I want to retrieve an object by passing the value of the function. But in example, it is done through hibernate config. I have not config sessionFactory bean in my classpath. I want to use JPA to retrieve the object. Here in the example, it is: But I
How to remove data source warnings in Spring Jpa and Intellij Idea?
After new update Intellij, I have red warnings in entity classes. For example: I have warning lines under “poll_answers” and “poll_id” “cannot resolve table/column” and offers me press “assign data source”. Answer Your setup: Spring, JPA, ORM Since your Spring p…
Error creating bean with name ‘entityManagerFactory’ defined in class path resource (Invocation of init method failed)
When I try to run my spring-boot project with hibernate and MySql, I got following error. My application.properties In pom.xml I have following dependencies, and my Course model looks like below, I also referred previous questions(Error creating bean with name ‘entityManagerFactory’ defined in cla…
Set default Transaction Manager in @Transactional annotations?
I have a Spring Boot 2.x application with JPA/Hibernate and 2 separate Transaction Managers: 1 per-tenant and 1 application-wide. All entities, repositories and services are separated in different packages. Whenever I use @Transactional in my services, I need to explicitly qualify the txManager as either @Tra…
JPA Bidirectional relationship throws java.lang.StackOverflowError: null
i’m trying to relate two entities with JPA, when i run the project don’t throws me errors but when i request the method that get me the Voters of a Comunity Leader i get the next Exception: I’ts like a loop, i don’t khow how to resolve this. Here are my classes: 1)Leader Entity : 2)Vot…