Skip to content
Advertisement

Tag: jpa

JPA many to many relationship causing infinite recursion

Edit: I solved the problem using @JsonIgnoreProperties in both classes I have two entities in my api. Pokemon which has a list of “types” that pokemon have and Type which has a list of “pokemon” that have that specific type. I’m trying to implement a getAll method in my controllers but i’m having an infinite recursion problem. I’ve tried to

JPA SQL Result Mapping

my code is mapping query result to DTO using Sql Result Mapping and create list with these dtos but in my database id can be null and it gives me trouble in mapping. That’s why I don’t want to use it instead of that, is there any way to generate id’s for these dto’s not getting them from sql query?

Select the top row in JPQL without using native query option

How is it possible to select the first row at the top of the selection without using native query option in JPQL/JPA? Answer You might be able to use a max subquery here to restrict to the “first” row: This would be logically correct if orderNumber would always be guaranteed to be unique, in which case there would only be

JPA cascade actions on one-to-one relationship

I have the following question regarding one to one relationships (and I guess one to many also): Let’s suppose I have the following tables: As you can see the two tables share the same primary key. Now the entities I created are the following: When I try to persist a new user I have a user object with all the

JPA @PreUpdate @Persist seems not working as expected

I have a problem for filling auditing fields by using @PreUpdate and @PrePersist. For instance When I’d like to update a client entity, the field updatedBy and updatedAt are still null; despite when I debug, the code of preUpdate() which is annotated with @PreUpdate is executed. Below the code of AuditingField which is responsible for creating/updating the auditing fields in

Advertisement