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
Tag: jpa
Bind two Entity without intermediate Entity spring data jpa
I have a user table(and entity) and user groups group users are stored in bind table I want to have in my group entity list of userEntity(without bind entity). Any ideas? Of course, I can use @Query annotation, but I have other entities who mapped with group and they will automatic get group entity. Can I override automatical methods? Answer
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?
Thymeleaf’s form dont return the object to controller class’s method
I have a SpringBoot-MVC Java application with JPA/Hibernate, using a H2 database to store data and I’m trying to read and change lines of this database through web browser. I had success with the reading, but the edit page’s form with thymeleaf does not send the object I alterated to controller class. The formulary: The method that should receive the
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
How to load the collection of a LAZY association for an already found entity
Consider the following: @Entity @Table(name = “cars”) public class Car { @Id private int id; private String name; @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType….
How to update a JSONB column in PostgreSQL using a Spring Data JPA Query
I have the following Controller If i remove/comment That is i don’t add the fetched result to the new updatedAdditionDetails (of type ArrayList), the DB updates successfully Otherwise i get the below error : ERROR: column “itemsinventory_addtion_details” is of type jsonb but expression is of type recordn Hint: You will need to rewrite or cast the expression.n Position In my
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
JPA @OnetoOne self reference relationship with both columns non null
I have an existing database table For e.g. T_STUDENTS on top of which I have to create a JPA entity. All three columns in the table are NON NULL and the table has a self-reference as mentor_id Each student has a mentor who is also a student. There is a strict OneToOne relationship between the student and the mentor. For