is there a particularly good way to do this? I have used Panache/Hibernate ORM to extend the PanacheEntity to create a mapping for the schema for a new table. Everything works as expected using the Repository method and I have the proper endpoints that reflect GETs, PUTs, etc. My current issue is that I was trying to have an entirely different endpoint that ONLY does a GET on a Postgresql Function/Stored Procedure and return that data when you hit that endpoint. This is the endpoint -
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/holidays")
@Produces("application/json")
@Consumes("application/json")
public class HolidayResource {
@Inject
EntityManager entityManager;
@GET
public Holiday[] get() {
return entityManager.createNamedQuery("Holidays.findAll", Holiday.class)
.getResultList().toArray(new Holiday[0]);
}
}
And this is the object/class -
import java.sql.Date;
import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.annotations.NamedNativeQuery;
@Entity
@NamedNativeQuery(name = "Holidays.findAll", query = "SELECT * FROM holidays.usa('NY', 2020, 2020)")
public class Holiday {
public static enum Authority {
federal,
national,
bank,
provincial,
state,
informal,
observance,
shortened_work_day,
optional,
de_facto,
religious,
extra_work_day,
municipal
}
@Id public long id;
public Date datestamp;
public String description;
public Authority authority;
public Boolean day_off;
public Boolean observation_shifted;
public Timestamp start_time;
public Timestamp end_time;
}
Note that I'm not trying to create a Table or anything only just to display. This is the stack trace, but I've tried a few things that seem to kinda have me going in circles (such as adding getters/setters and other things) -
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServerAfterFailedStart(VertxHttpRecorder.java:223)
at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup.handleFailedInitialStart(VertxHttpHotReplacementSetup.java:37)
at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.startupFailed(RuntimeUpdatesProcessor.java:662)
at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:137)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:378)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:56)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:127)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:84)
at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:144)
at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:106)
at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:57)
at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServerAfterFailedStart(VertxHttpRecorder.java:195)
... 9 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:106)
at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:79)
... 11 more
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:106)
at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:79)
... 12 more
Caused by: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
at io.smallrye.config.SmallRyeConfig.lambda$getConverter$2(SmallRyeConfig.java:292)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
at io.smallrye.config.SmallRyeConfig.getConverter(SmallRyeConfig.java:289)
at io.quarkus.runtime.configuration.ConfigInstantiator.getConverterFor(ConfigInstantiator.java:121)
at io.quarkus.runtime.configuration.ConfigInstantiator.getConverterFor(ConfigInstantiator.java:117)
at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:91)
... 13 more
The Postgres function/stored procedure was created off a Python script that I found somewhere and it would be invoked like so for example and is reflected in the @NamedNativeQuery
annotation. -
SELECT * from holidays.usa('NY', 2020, 2020);
An example of the return from the Query -
datestamp description authority day_off observation_shifted start_time end_time
[DATE] [TEXT] [ENUM] [BOOLEAN] [BOOLEAN] [TIME] [TIME]
------------ ----------------------- ----------- --------- ------------------- ---------- ----------
"2020-01-01" "New Year's Day" "federal" true false "00:00:00" "24:00:00"
"2020-02-17" "Family Day" "provincial" true false "00:00:00" "24:00:00
Is there a better way to do this? A few of the things I've tried seem to drive me into the wrong circle.