Santo
Santo
JCHJava Community | Help. Code. Learn.
Created by Santo on 12/2/2024 in #java-help
Gradle H2 issue with MSSQLServer Mode
Our app is in Spring boot 3, with Gradle in a multi module project and in our test conf we're using ghe datasource url with MODE=MSSQLServer Now we tried refactoring our code to make it a monolith, but the H2 database now has issues with all the Sql server sql's (like SP_RENAME) I checked everything 3 times and I don't see any changes that could cause this, and I even found that even H2 with the mode should not be able to handle these kind of sql commands, but how was it working before ?
8 replies
JCHJava Community | Help. Code. Learn.
Created by Santo on 2/14/2024 in #java-help
OpenAPI-Swagger webflux Spring boot 3
I don't know why in my Swagger, I see only one of my two routes
@Configuration
public class IngredientRouter {

private static final String BASE_URL = "/ingredient/";

@RouterOperations({
@RouterOperation(path = BASE_URL, method = RequestMethod.GET, beanClass = IngredientService.class, beanMethod = "getAllIngredients"),
@RouterOperation(path = BASE_URL + "{name}", method = RequestMethod.GET,beanClass = IngredientService.class, beanMethod = "getAllIngredientsStartingWith")
})
@Bean
public RouterFunction<ServerResponse> ingredientRoute(IngredientHandler handler) {
return RouterFunctions
.route(GET(BASE_URL).and(accept(MediaType.APPLICATION_JSON)), handler::getAllIngredients)
.andRoute(GET(BASE_URL + "{name}").and(accept(MediaType.APPLICATION_JSON)), handler::getAllIngredientsStartingWith);
}
@Configuration
public class IngredientRouter {

private static final String BASE_URL = "/ingredient/";

@RouterOperations({
@RouterOperation(path = BASE_URL, method = RequestMethod.GET, beanClass = IngredientService.class, beanMethod = "getAllIngredients"),
@RouterOperation(path = BASE_URL + "{name}", method = RequestMethod.GET,beanClass = IngredientService.class, beanMethod = "getAllIngredientsStartingWith")
})
@Bean
public RouterFunction<ServerResponse> ingredientRoute(IngredientHandler handler) {
return RouterFunctions
.route(GET(BASE_URL).and(accept(MediaType.APPLICATION_JSON)), handler::getAllIngredients)
.andRoute(GET(BASE_URL + "{name}").and(accept(MediaType.APPLICATION_JSON)), handler::getAllIngredientsStartingWith);
}
45 replies
JCHJava Community | Help. Code. Learn.
Created by Santo on 2/12/2024 in #java-help
Reactive Repository MongoDB not finding methods
Trying to use Reactive programming in a web app, but it seems that Intellij doesn't find any other method than my findAllBy in my repository, I mean crud methods, isn't it integrated to it ?
public interface CocktailRepository extends ReactiveSortingRepository<Cocktail, String>{
Flux<Cocktail> findAllBy(Pageable pageable);
}
public interface CocktailRepository extends ReactiveSortingRepository<Cocktail, String>{
Flux<Cocktail> findAllBy(Pageable pageable);
}
@GetMapping("/cocktails")
public Mono<Page<Cocktail>> getAllCocktails(Pageable pageable) {
return cocktailRepository.findAllBy(pageable)
.collectList()
.zipWith(cocktailRepository.count())
.map(c -> new PageImpl<>(c.getT1(), pageable, c.getT2()));
}
@GetMapping("/cocktails")
public Mono<Page<Cocktail>> getAllCocktails(Pageable pageable) {
return cocktailRepository.findAllBy(pageable)
.collectList()
.zipWith(cocktailRepository.count())
.map(c -> new PageImpl<>(c.getT1(), pageable, c.getT2()));
}
In Spring documentation: https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/reactive/ReactiveSortingRepository.html It says : In many cases it should be combined with ReactiveCrudRepository or a similar repository interface in order to add CRUD functionality. Does that mean that I have to create another repository for CRUD operations and use the Sorting one only for pagination ?
4 replies
JCHJava Community | Help. Code. Learn.
Created by Santo on 1/3/2024 in #java-help
Advanced Java material to get better?
I have around 6 years professionnal experience and I feel like I start to lag behind in the best practices for Java/Spring-boot, mostly due to the fact that I have little occasions to work on something interesting and challenging at work, like optimization for example. I'd love to know what material (video, pdf, ...) I can use to actually get better at using design patterns and the latest Java versions. I'm already looking at the documentation and trying to learn from it.
9 replies