{"record":{"id":"6d91fd154d60bcd1","repo":"quarkusio/quarkus","slug":"stateless-operations-not-supported-6d91fd","errorCode":null,"errorMessage":"Stateless operations not supported","messagePattern":"Stateless operations not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions/data/hibernate/runtime/src/main/java/io/quarkus/data/hibernate/runtime/orm/ManagedBlockingOperations.java","lineNumber":32,"sourceCode":"import io.quarkus.data.hibernate.runtime.spi.PanacheBlockingOperations;\n\npublic class ManagedBlockingOperations implements PanacheBlockingOperations {\n\n    public final static ManagedBlockingOperations INSTANCE = new ManagedBlockingOperations();\n    private final static ManagedBlockingJpaOperations DELEGATE = new ManagedBlockingJpaOperations();\n\n    private ManagedBlockingOperations() {\n    }\n\n    @Override\n    public Session getSession(Class<?> entityClass) {\n        return DELEGATE.getSession(entityClass);\n    }\n\n    @Override\n    public StatelessSession getStatelessSession(Class<?> entityClass) {\n        // FIXME: this is wrong\n        throw new UnsupportedOperationException(\"Stateless operations not supported\");\n    }\n\n    @Override\n    public Void insert(Object entity) {\n        throw new UnsupportedOperationException(\"Stateless operations not supported\");\n    }\n\n    @Override\n    public Void persist(Object entity) {\n        DELEGATE.persist(entity);\n        return null;\n    }\n\n    @Override\n    public Void persistAndFlush(Object entity) {\n        DELEGATE.persist(entity);\n        DELEGATE.flush(entity);\n        return null;","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/data/hibernate/runtime/src/main/java/io/quarkus/data/hibernate/runtime/orm/ManagedBlockingOperations.java#L14-L50","documentation":"ManagedBlockingOperations wraps a managed (persistence-context) blocking Hibernate Session. getStatelessSession(entityClass) would need to hand out a StatelessSession, which the managed delegate cannot provide (the source even marks it with a FIXME). Because managed operations objects never expose stateless sessions, the method throws UnsupportedOperationException.","triggerScenarios":"Calling getStatelessSession(SomeEntity.class) on a managed blocking operations/session wrapper, e.g. generic code that obtains either a managed or stateless view depending on context.","commonSituations":"Utility code abstracting over both managed and stateless access paths; developers trying to mix stateless batch operations into a managed session handle; version drift where the managed wrapper's API surface grew but stateless support was not implemented.","solutions":["Obtain the StatelessSession directly from the session factory (openStatelessSession) instead of via the managed wrapper","Use the dedicated stateless operations object for stateless work (insert/upsert/delete)","Restructure code so managed and stateless operations use separate, explicitly obtained handles","Track upstream Quarkus updates in case the FIXME is resolved and stateless support is added"],"exampleFix":"// before\nStatelessSession sss = managedOps.getStatelessSession(User.class);\n// after\nStatelessSession sss = sessionFactory.openStatelessSession();","handlingStrategy":"try-catch","validationCode":"// do not request a stateless session from a managed wrapper\n// obtain it from the factory instead:\n// StatelessSession sss = sessionFactory.openStatelessSession();","typeGuard":null,"tryCatchPattern":"StatelessSession sss;\ntry {\n    sss = managedOps.getStatelessSession(User.class);\n} catch (UnsupportedOperationException e) {\n    sss = sessionFactory.openStatelessSession();\n}","preventionTips":["Get StatelessSession only from the SessionFactory (openStatelessSession)","Keep stateless batch code on its own handle, separate from managed sessions","Watch the upstream FIXME — do not rely on this method existing"],"tags":["hibernate","orm","blocking","stateless-session"],"backgroundTag":"unsupported-persistence-context-operation","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}