Skip to content

Tag: spring

Java Spring omits fields when making a JSON

I have an object that looks more or less like this, and I use it as a GET response for my API. scores and values are both database entities. I wanted to add a String to the response with some additional information. What happens is that the objects are properly turned into a JSON and they show up in the

Convert fields before sending to the page

I have a user dto class and i need to convert some of its properties before send it to frontend. UsedDto class Now, from my controller i get data like this In my case, before send data, i should convert boolean values (enabled, active) to string “Y” or “N”. How can i do this? Answer Yo…

Application failed after added swagger configuration

I’m using spring boot and I want to add swagger configuration, the problem is after I run the application I get this error: In my class I added this methods: In my pom.xml I added this dependencies: I can’t understand what is wrong, I followed online solution asking me to add @EnableSwagger2WebMv …

My Spring JPA queries do not work with H2

This query below does not work and it generates me an exception When I used the MySQL database, the query worked fine. But now that I am using the H2 database, it suddenly does not work. Why? How do I fix this? Answer It would be better to use JPA. If you still wanna use nativeQuery, use like this: