diff --git a/src/de/steamwar/sql/Event.java b/src/de/steamwar/sql/Event.java index 7985232..a853e13 100644 --- a/src/de/steamwar/sql/Event.java +++ b/src/de/steamwar/sql/Event.java @@ -32,6 +32,10 @@ import java.util.List; @AllArgsConstructor public class Event { + static { + SchematicType.Normal.name(); // Ensure SchematicType is loaded. + } + private static final Table table = new Table<>(Event.class); private static final SelectStatement byCurrent = new SelectStatement<>(table, "SELECT * FROM Event WHERE Start < now() AND End > now()"); diff --git a/src/de/steamwar/sql/NodeDownload.java b/src/de/steamwar/sql/NodeDownload.java index 585b3db..666cf68 100644 --- a/src/de/steamwar/sql/NodeDownload.java +++ b/src/de/steamwar/sql/NodeDownload.java @@ -26,7 +26,7 @@ import lombok.AllArgsConstructor; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.security.Timestamp; +import java.sql.Timestamp; import java.time.Instant; @AllArgsConstructor diff --git a/src/de/steamwar/sql/SchematicNode.java b/src/de/steamwar/sql/SchematicNode.java index 7bedbdc..6002739 100644 --- a/src/de/steamwar/sql/SchematicNode.java +++ b/src/de/steamwar/sql/SchematicNode.java @@ -20,9 +20,7 @@ package de.steamwar.sql; import de.steamwar.sql.internal.*; -import lombok.AccessLevel; import lombok.Getter; -import lombok.Setter; import java.sql.Timestamp; import java.time.Instant; @@ -32,6 +30,7 @@ import java.util.function.Predicate; public class SchematicNode { static { + SchematicType.Normal.name(); // Ensure SchematicType is loaded. new SqlTypeMapper<>(SchematicNode.class, null, (rs, identifier) -> { throw new SecurityException("SchematicNode cannot be used as type (recursive select)"); }, (st, index, value) -> st.setInt(index, value.nodeId)); } diff --git a/src/de/steamwar/sql/internal/SqlTypeMapper.java b/src/de/steamwar/sql/internal/SqlTypeMapper.java index 34c6173..53a2cc2 100644 --- a/src/de/steamwar/sql/internal/SqlTypeMapper.java +++ b/src/de/steamwar/sql/internal/SqlTypeMapper.java @@ -32,7 +32,12 @@ public final class SqlTypeMapper { private static final Map, SqlTypeMapper> mappers = new IdentityHashMap<>(); public static SqlTypeMapper getMapper(Class clazz) { - return (SqlTypeMapper) mappers.get(clazz); + SqlTypeMapper result = (SqlTypeMapper) mappers.get(clazz); + + if(result == null) + throw new SecurityException("Unregistered mapper requested: " + clazz.getName()); + + return result; } public static > void ordinalEnumMapper(Class type) {