I have multiple @Service class which implements a class BaseService In a Controller class, I want to call a Service class (which implements BaseService) based on a parameter I’m using a function in Utils and calling it from the Controller class My TestService class has an @Service annotation TestService…
Tag: spring-boot
How to reuse validator class in spring boot app?
I am currently writing custom validator for Spring Boot app and its idea is mainly to do some validations depending on other validations. For example, I want one field to be @NotNull if some other field is null, but the idea is to make it more generic, so that this conditional validations can be changed. For …
JPA pagination query becomes slower with every subsequent call
Project has Spring Boot with JPA. We have a table vehicle with 1m+ records. Table has an indexed field type. We have a use case, where we want to fetch all the records by type. For each type, we get all the vehicle records, then for next type, then for next and so on. Since there are 1m+ records, we
Spring Boot cannot create database table in mysql 5.7
I’d like to create a table called dni with that information in mysql server. Querys that failed: 1.”create table dni (id bigint not null, apellidos varchar(255), codigo_dni varchar(255), direccion varchar(255), fecha_nacimiento varchar(255), foto_perfil varchar(255), nombre varchar(255), primary k…
Unable to load config data to springboot application from mounted volume in kubernetes
I have springboot application and I am trying to load additional configuration from a volume mounted location /tmp/secret-config.yaml and getting below error: java.lang.IllegalStateException: Unable to load config data from ‘/tmp/secret-config.yaml’ I do not want to use configmap or secrets for th…
How to create RESTful Web Service with Spring Boot and Apache Camel?
I’m learning Apache Camel in Spring Boot project and I try to create a Retful Webservice and the service is starting but the problem is that I get 404 when I call the endpoint. I created this class to hardcode some data: application.yml pom.xml The serviceis starting and this is the console log: But whe…
Translate SQL into Hibernate HQL
I’m using Spring boot along with Hibernate. I’ve only recently started using Java so I’m not quite good at it. I have a OneToMany unidirectional relationship with a join table. RssUrl Table User Table Join table I’m trying to translate this SQL into HQL It’s basically checking if…
Relationship mapping in Hibernate Java – save owning side entity
I have 2 tables User Url I’m trying to create a relationship between said 2 tables. A user can have many urls, but a url can belong to only one user. This sounds to me like a OneToMany relationship. My User Entity is as follows(some code was removed as to not make it too long): My Url Entity is as
Throwing custom errors as Json when a parameter is invalid
I am working on an API and need to throw and exception that looks like this if the sort by parameter is not one of my predetermined values, i have a few parameters to do this for here is what my controller looks like ive remove the url but it works for sorting the incoming data but i need to
Calling blocking endpoint on non-blocking asynchronous service
If my reactive endpoint needs to call an external, non-reactive endpoint which does blocking stuff, is my reactive endpoint still reactive? I have 2 services running that levergaes Spring Boot MVC and Spring Webflux. Service A Spring Webflux Service B Spring MVC Now my Service A which is reactive calling the …