I have some troubles with Spring JPA relationships. I have two entities: Gift and Candy. And I want user to be able to select available candy and add it to gift. How can I do that using spring jpa? I’ve already tried ‘one to many’ relationship with gift as owning side, and I got “null …
Tag: spring
set Content-Type to application/Json using Fetch API javascript
I am trying to send some form data to a spring application using Fetch API in javascript. I have this code to send the form data: but i get a 415 status error “Unsupported Media Type”. Even when i set specifically the header ‘Content-Type’ to ‘application/json’ it sends lik…
Variables are not coming up null during Postman call
Setting up an Java Postman call assigning values to the variables but its shows null. My Pojo Student Class Postman Request Answer your request body should be like this: because you are getting StudentRequest as RequestBody and it means you should send StudentRequest internal properties not containing Student…
The request is not being executed in rest controller test
I have a test method for one of the mappings where I provide all required data for the test Here is the controller itself But after running it I get this exception about failing to create Pageble object Answer The problem was solve by adding extra configuration for mockMvc
Error running a Java 8 batch with a jdk17
I’m trying to run a java 8 batch with a jdk17, the project is built with a jre1.8.0_192 and I put the following options in the VM: –add-modules=ALL-SYSTEM –add-opens=java.base/java.lang=ALL-UNNAMED –add-opens=java.base/java.math=ALL-UNNAMED –add-opens=java.base/java.net=ALL-UNNAM…
Sonar Issue-Possible null pointer dereference due to return value of called method. Return value from a method is dereferenced without a null check
I have a void method which is being called with a string argument from a parent method. Answer getText seems to be more than a simple getter. The second time it evidently may return null.
How to handle Docker-Secrets in application.properties files
How do you inject Docker secrets (files/data from /run/secrets) into the application.properties files? Is it safe to use environment variables? Answer First of all, usage of environment variables for secret data for the application.properties isn’t safe. You have mainly two options when talking about Se…
Use another MapStruct mapper only inside an expression clause
I have a mapper that, for a particular attribute of the target class, needs to choose one from a list of objects inside the source object, and map it using a differente mapper class. Simplifying it a lot, the Game class contains a list of Transaction objects, and my GameMapper class looks like this: The thing…
How to manage memory using Spring Boot Maven Plugin with Kubernetes
I’m using spring boot 2.5.6 and I’m generating the docker image with the spring boot maven plugin. I’m deploying the application using AWS EKS with nodes managed by fargate. The plugin configuration is the following The command I use to execute it is the following When the application is dep…
Can I extend MapStruct methods?
I’m developing a library and I expect the library to have a mapper like so: Which is meant for internal remapping. Now, I’d like to add a feature where the user can “override” this method, in the sense that they could for example add a statement to ignore the password of the account, w…