From a44233bea0e20e6316be57a37dc6e547bfb5b0e8 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 7 Oct 2018 01:46:34 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20m=C3=A9thode=20dans=20ORM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pandacube/java/external_tools/Main.java | 4 ---- .../java/fr/pandacube/java/util/orm/ORM.java | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/pandacube/java/external_tools/Main.java b/src/main/java/fr/pandacube/java/external_tools/Main.java index ea3e0bc..be3c9cd 100644 --- a/src/main/java/fr/pandacube/java/external_tools/Main.java +++ b/src/main/java/fr/pandacube/java/external_tools/Main.java @@ -1,12 +1,8 @@ package fr.pandacube.java.external_tools; -import java.io.FileReader; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; public class Main { diff --git a/src/main/java/fr/pandacube/java/util/orm/ORM.java b/src/main/java/fr/pandacube/java/util/orm/ORM.java index 049c178..bfcd053 100644 --- a/src/main/java/fr/pandacube/java/util/orm/ORM.java +++ b/src/main/java/fr/pandacube/java/util/orm/ORM.java @@ -161,6 +161,26 @@ public final class ORM { } } + + + public static ResultSet getCustomResult(String sql, List params) throws ORMException { + try { + try (PreparedStatement ps = connection.getNativeConnection().prepareStatement(sql)) { + + int i = 1; + for (Object val : params) { + if (val instanceof Enum) val = ((Enum) val).name(); + ps.setObject(i++, val); + } + Log.debug(ps.toString()); + + return ps.executeQuery(); + } + } catch (SQLException e) { + throw new ORMException(e); + } + + } @SuppressWarnings("unchecked") private static > E getElementInstance(ResultSet set, Class elemClass) throws ORMException {