Encountering governor limit errors in Salesforce is common, but one specific error often catches developers off guard: System.LimitException: Too many DML statements: 1 . This exception does not mean you have exceeded the standard 150 DML statement limit—it means you have attempted to execute even a single insert, update, or delete operation inside a strictly read-only execution context. In plain words: When a Visualforce page is configured with readOnly="true" (or an Apex method is marked with @ReadOnly ), Salesforce sets the maximum allowed DML statements to 0 . Any attempt to modify data triggers Too many DML statements: 1 immediately.
Apex Development