{"record":{"id":"51ffbc89ccea8b37","repo":"hibernate/hibernate-orm","slug":"event-name-to-resolve-cannot-be-null","errorCode":null,"errorMessage":"event name to resolve cannot be null","messagePattern":"event name to resolve cannot be null","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/event/spi/EventType.java","lineNumber":121,"sourceCode":"\n\t@Nonnull\n\tpublic static <T> EventType<T> create(@Nonnull String name, @Nonnull Class<T> listenerRole, int ordinal) {\n\t\treturn new EventType<>( name, listenerRole, ordinal, false );\n\t}\n\n\t/**\n\t * Find an {@link EventType} by its name\n\t *\n\t * @param eventName The name\n\t *\n\t * @return The {@link EventType} instance.\n\t *\n\t * @throws HibernateException If eventName is null, or if eventName does not correlate to any known event type.\n\t */\n\t@Nonnull\n\tpublic static EventType<?> resolveEventTypeByName(@Nonnull final String eventName) {\n\t\tif ( eventName == null ) {\n\t\t\tthrow new HibernateException( \"event name to resolve cannot be null\" );\n\t\t}\n\t\tfinal EventType<?> eventType = STANDARD_TYPE_BY_NAME_MAP.get( eventName );\n\t\tif ( eventType == null ) {\n\t\t\tthrow new HibernateException( \"Unable to locate proper event type for event name [\" + eventName + \"]\" );\n\t\t}\n\t\treturn eventType;\n\t}\n\n\t/**\n\t * Get a collection of all the standard {@link EventType} instances.\n\t */\n\t@Nonnull\n\tpublic static Collection<EventType<?>> values() {\n\t\treturn STANDARD_TYPE_BY_NAME_MAP.values();\n\t}\n\n\t/**\n\t * Used from {@link EventEngine} to \"prime\" the registered event-type map.","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/spi/EventType.java#L103-L139","documentation":"HibernateException from EventType.resolveEventTypeByName(null): the helper that maps event-name strings (the names used in hibernate.cfg.xml <event type=...> blocks and programmatic listener configuration) to EventType instances requires a non-null name and fails fast otherwise. It exists purely to give a clearer error than an NPE deep in map lookup.","triggerScenarios":"Passing a null event name — e.g. configuration parsing code that reads an event type attribute which is missing from the XML/properties and forwards the null into resolveEventTypeByName; generic bootstrap helpers accepting a nullable name parameter.","commonSituations":"Hand-edited hibernate.cfg.xml/hbm files with a malformed <event> element lacking its type attribute; custom configuration loaders that iterate configured event names and hit an unset entry; copy-paste config code where the name variable was never assigned.","solutions":["Validate the name before resolving: Objects.requireNonNull(name) at the config boundary with a message pointing at the offending entry","Fix the configuration source — supply the missing type attribute / filter out blank entries before parsing into listener registration","When the type is known statically, use EventType constants directly instead of name resolution"],"exampleFix":"// before\nString evtName = config.get(\"event.type\"); // missing in config -> null\nEventType<?> t = EventType.resolveEventTypeByName(evtName); // event name to resolve cannot be null\n\n// after\nString evtName = Objects.requireNonNull(config.get(\"event.type\"), \"'event.type' must be set\");\nEventType<?> t = EventType.resolveEventTypeByName(evtName);","handlingStrategy":"validation","validationCode":"String name = Objects.requireNonNull(config.get(\"event.type\"), \"'event.type' missing in configuration\");\nEventType<?> t = EventType.resolveEventTypeByName(name);","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Validate parsed configuration keys before feeding them to Hibernate APIs","Use schema-validated config binding (Spring Boot @ConfigurationProperties) that rejects missing attributes","Prefer EventType constants over name strings where possible"],"tags":["hibernate","event-type","configuration","validation","null-check"],"backgroundTag":"null-config-value","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}