diff --git a/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java b/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java index 3f8e709f193ec..e652d6338740f 100644 --- a/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java +++ b/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java @@ -56,6 +56,12 @@ void registerAuthenticationPlugins(BuildProducer servi .produce(ServiceProviderBuildItem.allProvidersFromClassPath("org.mariadb.jdbc.plugin.AuthenticationPlugin")); } + @BuildStep + void registerCodecs(BuildProducer serviceProvider) { + serviceProvider + .produce(ServiceProviderBuildItem.allProvidersFromClassPath("org.mariadb.jdbc.plugin.Codec")); + } + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) void addNativeImageResources(BuildProducer resources) { // mariadb.properties is used by org.mariadb.jdbc.util.VersionFactory and is small enough. diff --git a/integration-tests/jpa-mariadb/src/main/java/io/quarkus/it/jpa/mariadb/JPAFunctionalityTestEndpoint.java b/integration-tests/jpa-mariadb/src/main/java/io/quarkus/it/jpa/mariadb/JPAFunctionalityTestEndpoint.java index 920ef8059647e..21f6c11931ced 100644 --- a/integration-tests/jpa-mariadb/src/main/java/io/quarkus/it/jpa/mariadb/JPAFunctionalityTestEndpoint.java +++ b/integration-tests/jpa-mariadb/src/main/java/io/quarkus/it/jpa/mariadb/JPAFunctionalityTestEndpoint.java @@ -2,9 +2,13 @@ import java.io.IOException; import java.io.PrintWriter; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.List; import java.util.UUID; +import javax.inject.Inject; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; @@ -17,6 +21,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.sql.DataSource; /** * Basic test running JPA with the MariaDB database. @@ -28,10 +33,13 @@ public class JPAFunctionalityTestEndpoint extends HttpServlet { @PersistenceUnit(unitName = "templatePU") EntityManagerFactory entityManagerFactory; + @Inject + DataSource ds; + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { try { - doStuffWithHibernate(entityManagerFactory); + doStuffWithHibernate(entityManagerFactory, ds); } catch (Exception e) { reportException("An error occurred while performing Hibernate operations", e, resp); } @@ -41,7 +49,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO /** * Lists the various operations we want to test for: */ - private static void doStuffWithHibernate(EntityManagerFactory entityManagerFactory) { + private static void doStuffWithHibernate(EntityManagerFactory entityManagerFactory, DataSource ds) throws SQLException { //Cleanup any existing data: deleteAllPerson(entityManagerFactory); @@ -52,6 +60,9 @@ private static void doStuffWithHibernate(EntityManagerFactory entityManagerFacto //Load all persons and run some checks on the query results: verifyListOfExistingPersons(entityManagerFactory); + //Try to use prepared statement with setObject: + verifyGetPersonUsingSetObject(ds); + //Try a JPA named query: verifyJPANamedQuery(entityManagerFactory); @@ -150,4 +161,18 @@ private void reportException(String errorMessage, final Exception e, final HttpS writer.append("\n\t"); } + private static void verifyGetPersonUsingSetObject(final DataSource ds) throws SQLException { + getExistingPersonUsingSetObject(ds); + } + + private static void getExistingPersonUsingSetObject(DataSource ds) throws SQLException { + try (PreparedStatement ps = ds.getConnection().prepareStatement("select * from Person as p where p.name = ?")) { + ps.setObject(1, "Quarkus"); + final ResultSet resultSet = ps.executeQuery(); + + if (!resultSet.next()) { + throw new RuntimeException("Person Quarkus doesn't exist when it should"); + } + } + } } diff --git a/integration-tests/jpa-mariadb/src/main/resources/application.properties b/integration-tests/jpa-mariadb/src/main/resources/application.properties index 05d96600bb238..3d37fc478ca2d 100644 --- a/integration-tests/jpa-mariadb/src/main/resources/application.properties +++ b/integration-tests/jpa-mariadb/src/main/resources/application.properties @@ -2,4 +2,4 @@ quarkus.datasource.db-kind=mariadb quarkus.datasource.username=hibernate_orm_test quarkus.datasource.password=hibernate_orm_test quarkus.datasource.jdbc.url=${mariadb.url} -quarkus.datasource.jdbc.max-size=1 +quarkus.datasource.jdbc.max-size=2