Ajout méthode dans ORM
This commit is contained in:
parent
6e5cdd16af
commit
a44233bea0
@ -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 {
|
||||
|
||||
|
@ -162,6 +162,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 {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user