I am building the Rest API with Java, Spring Boot, Hibernate and JPA. I have 2 tables Users and Friends, where User will have an array of Friend. My client will send several update request on my User table. This the request the API will receive : If my client send this request, my API returns : This answer is
Tag: spring-data-jpa
How to use Spring Specification to filter through many to many realtionship?
I decided to create filters in my application with Spring Specification. Everything was going well but I don’t know to do filter User events. Which filter events by user login. My entities look like this: I read many subjects on stack but still don’t know to how to implement my filter logic and filter beginning looks like this: Answer I
Implement Search specification for pagination
I implemented this Page request: The question is how to implement search functionality for this Page request? I would like to send params like type and dateAdded into GET params and return filtered result? Answer There are two ways to achieve this: Examples. Simple but can only be used for simple searches To be able to search by example, you
Error accessing field by reflection for persistent property [model.Credentials#email] on @EmbeddedID
I’ve been experiencing problems implementing the Authorities on my spring boot application, and after digging a little I realised that maybe the association between my Credentials and Authorities tables, was wrong. In fact it come to my attention that Spring allowed every type of user, (regardless their authority) to access ever method, even the ones I though have been secured.
Why does Javers store the ID of my audited entities wrapped in quotes?
I audit changes to a com.example.TaskSupplier entity with Javers by annotating the corresponding Spring Data repository The primary key of this entity is a UUID, so I can retrieve an instance with However, the entry in Javers’ jv_global_id table for this instance wraps the ID in quotes, so in order to retrieve the corresponding row from this table, I have
JPA ManToMany association and insert, retrieve data with Spring Data Repository
I need to setup many to many relationship between 2 entities, namely Project and Articles. The use case is a project that can be linked to many articles which are related. So does each article will be linked to various projects. I am using Spring data repository in my project and having trouble persisting and retrieving this relationship with the
How to annotate Map with JPA?
The app’s stack: Spring MVC, Spring DataJPA, Hibernate. There are three entities: student, tutor, theme. Theme: Student: Tutor: For save student-tutor-theme relationships i want use this table (PostgreSQL): How i can to annotate tutors and students fields in entities, for their content correct persists in this table? Answer Like @kolossus mentioned: Use the @MapKeyJoinColumn¹ annotation, so that the classes (or
Retrieving limited columns using jpa specifications
I am using spring boot JPA specifications for executing complex queries. However, the table I am querying contains more than 20 columns and I need to pull just 3. I tried cq.multiselect(…) but it didn’t work and returned me the entity with all the columns. On investigation, I got to know that it’s a bug with specifications that’s not yet
Spring Data JPA – Get all elements
I’m new to Spring Data JPA and I want to ask if there is a method that can be used to fetch all items, not by a certain criterion. Any help would be helpful. Answer Use the findAll method from repository Take a look here Spring Data JPA API Look here a small example that will fetch all MyObj objects
Unable to Run my Spring Security MVC WebApp SpringChainFilter throwing exception, rawPassword cannot be null
So I was trying to make a simple spring security hardcoded security just to check how my app is working before connecting it to the DB but before that it start showing me error 500. Here is my Configuration file Here is my webSecurity Configuration class with In memory authentication with some sample data. Here is my Servlet Initializer Class