{"record":{"id":"b81bfbec13ef43b0","repo":"hibernate/hibernate-orm","slug":"unknown-access-type","errorCode":null,"errorMessage":"Unknown access type [","messagePattern":"Unknown access type \\[","errorType":"exception","errorClass":"UnknownAccessTypeException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/cache/spi/access/AccessType.java","lineNumber":88,"sourceCode":"\t *\n\t * @see #getExternalName()\n\t */\n\t@Nullable\n\tpublic static AccessType fromExternalName(@Nullable String externalName) {\n\t\tif ( externalName == null ) {\n\t\t\treturn null;\n\t\t}\n\t\tfor ( AccessType accessType : AccessType.values() ) {\n\t\t\tif ( accessType.getExternalName().equals( externalName ) ) {\n\t\t\t\treturn accessType;\n\t\t\t}\n\t\t}\n\t\t// Check to see if making upper-case matches an enum name.\n\t\ttry {\n\t\t\treturn AccessType.valueOf( externalName.toUpperCase( Locale.ROOT ) );\n\t\t}\n\t\tcatch ( IllegalArgumentException e ) {\n\t\t\tthrow new UnknownAccessTypeException( externalName );\n\t\t}\n\t}\n}\n","sourceCodeStart":70,"sourceCodeEnd":92,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/cache/spi/access/AccessType.java#L70-L92","documentation":"Hibernate resolves the textual name of a second-level cache concurrency strategy by matching it against the AccessType enum: first by external name (read-only, read-write, nonstrict-read-write, transactional), then by enum constant name case-insensitively. If the supplied string matches neither, AccessType.fromExternalName throws UnknownAccessTypeException carrying that name. The string almost always comes from a cache usage setting in an annotation, an hbm.xml mapping, or a configuration property.","triggerScenarios":"Calling AccessType.fromExternalName(name) with an unrecognized string; usage=\"read_write\" (underscore) in @org.hibernate.annotations.Cache or <cache usage=\"read_write\"/> in hbm.xml; hibernate.cache.default_cache_concurrency_strategy set to a misspelled value; provider configuration feeding a strategy name into Hibernate at startup.","commonSituations":"Typos in the cache usage attribute (read_write, nonstrictread_write, 'readwrite'); copying strategy names from another cache library; picking a strategy the configured cache provider does not offer; version upgrades where strategy name validation became stricter.","solutions":["Use one of the exact external names: read-only, read-write, nonstrict-read-write, transactional","Prefer the enum in code: @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) or AccessType.READ_WRITE instead of raw strings","Verify the configured cache provider actually supports the chosen strategy (e.g. transactional needs a JTA-capable provider)","Remove the usage attribute entirely to accept the provider default instead of an invalid name"],"exampleFix":"// before (hbm.xml)\n<cache usage=\"read_write\" region=\"items\"/>\n\n// after\n<cache usage=\"read-write\" region=\"items\"/>","handlingStrategy":"validation","validationCode":"private static final Set<String> VALID_STRATEGIES =\n        Set.of(\"read-only\", \"read-write\", \"nonstrict-read-write\", \"transactional\");\n\nif (cacheStrategyName != null && !VALID_STRATEGIES.contains(cacheStrategyName)) {\n    throw new IllegalArgumentException(\"Unknown cache access type: \" + cacheStrategyName\n            + \" (expected one of \" + VALID_STRATEGIES + \")\");\n}","typeGuard":"static boolean isValidAccessTypeName(String name) {\n    return Arrays.stream(AccessType.values()).anyMatch(\n            t -> t.getExternalName().equals(name) || t.name().equalsIgnoreCase(name));\n}","tryCatchPattern":"try {\n    AccessType type = AccessType.fromExternalName(configuredValue);\n} catch (UnknownAccessTypeException e) {\n    throw new IllegalStateException(\n            \"Invalid cache strategy '\" + configuredValue + \"' in configuration\", e);\n}","preventionTips":["Validate cache strategy names at startup before building the SessionFactory","Use AccessType or CacheConcurrencyStrategy enum constants instead of strings in code","Add an integration test that builds the SessionFactory with the production cache configuration"],"tags":["hibernate","second-level-cache","configuration","enum-parsing"],"backgroundTag":"invalid-cache-strategy-name","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}