Ajout méthode dans ORM

This commit is contained in:
Marc Baloup 2018-10-07 01:46:34 +02:00
parent 6e5cdd16af
commit a44233bea0
No known key found for this signature in database
GPG Key ID: 3A4F019B6C600FDE
2 changed files with 20 additions and 4 deletions

View File

@ -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 {

View File

@ -161,6 +161,26 @@ public final class ORM {
}
}
public static ResultSet getCustomResult(String sql, List<Object> 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 extends SQLElement<E>> E getElementInstance(ResultSet set, Class<E> elemClass) throws ORMException {