October 22, 2024
Chicago 12, Melborne City, USA
java

Knowing all the cucumber tags related to a set of test cases before running them in Java

I am working on a test project in Java using Cucumber and JUnit5. I am running both API and UI test cases for a web application. For the API test cases we are using XSRF tokens as an extra layer of security (besides the usual bearer token). Today I am getting this token in the

Read More
java

HikariCP-Oracle Connection Pool Recreated on Every Invocation in Java Micronaut Azure Function

I’m working on a Java application built with the Micronaut framework that leverages Azure Functions for a serverless design. The application connects to an Oracle database. However, I’ve encountered an issue where a new connection pool is being created on every single function invocation. This leads to a rapid increase in the number of active

Read More
java

Type inference error when generic class constructor builds an instance of another generic class with bounded type

When type parameter is bounded (T extends Comparable<? super T>), I encounter a type inference problem using <> to let the compiler infer the type in the following example: import java.util.Comparator; import java.util.Set; import java.util.TreeSet; public class InferTypeArgApp { static class ACollection<E extends Comparable<? super E>> { // static class ACollection<E> { // <-- If

Read More
java

Tomcat and Spring: Issue with Query Param Being Truncated (EVAL Keyword)

I’m encountering an issue with my Spring application running on a standalone Tomcat server (version 8.5.92), where a query parameter value is getting truncated under specific conditions. Problem: I’m making the following POST request using Postman and cURL to my Spring Boot application: curl --location 'http://localhost:8085/studies/S_STD01(TEST)/roles?siteOid=S_EVAL(TEST)' The issue is that when the query parameter siteOid=S_EVAL(TEST)

Read More
java

Looping to get TextField values out of TilePane

Hey all I am having a difficult time trying to get my textfield values out of my TilePane. The tree is this: This is what it visually looks like: My code: for (Node node : Agency_Contacts.getChildrenUnmodifiable()) { ObservableList<Node> childrens = Agency_Contacts.getChildren(); for (Node node1 : childrens) { if(node1 instanceof Pane) { ObservableList<Node> n = ((Pane)

Read More
java

How to send Multipart form data with restTemplate Spring-mvc

I try send request via RestClient: fun uploadFile(file: MultipartFile): MyDtoRs { val resource: Resource = file.resource val parts = LinkedMultiValueMap<String, Any>() parts.add("file", resource) val httpHeaders = HttpHeaders() httpHeaders.contentType = MediaType.MULTIPART_FORM_DATA val httpEntity = HttpEntity(parts, httpHeaders) val restClient = RestClient.create() return restClient.post() .uri("my/url") .body(httpEntity) .retrieve() .toEntity(MyDtoRs::class.java) .body!! } When sending the MultipartFile body via RestClient, I

Read More
java

How do i convert this SQL query into a criteriaBuilder\JPA method?

I am using Java 8. I have a SQL database with nodeId, name, ipaddress, and status. I have a class called ServerDao and a DTO class called ServersDto. I want my method to ping the ipaddresses in my database, and for the status column to change to up or down whether they ping or not.

Read More
java

Group by returning lists or values in spring jpa

I’m trying to do something really simple, but I somehow can’t make it work without a native query. Here is my entity: public class A { private long id private String key private UUID value } In my repository, I have the following method: @Query(value = """ SELECT key as key, ARRAY_AGG(value) AS values FROM

Read More
java

How can I optimize a large Java application using multi-threading without causing resource contention?

I’m working on a Java application that handles a large volume of data processing tasks. Currently, the application runs sequentially, but I want to improve performance by introducing multi-threading. However, I am concerned about potential resource contention and race conditions. Here are some specifics: The tasks involve frequent access to shared resources, including reading and

Read More
java

Custom join in a @ManyToMany or @OneToMany mapping without join table

I’m trying to define a custom join condition between the two following entities. class Period { private long id; private String category; private Date start; private Date end; @ManyToMany // Or @OneToMany private Collection<Event> events } class Event { private long id; private String category; private Date date; } I want to retrieve in Period

Read More