You need to sign in to do that
Don't have an account?
Rocks_SFDC
How to Use @readOnly Annotation in Apex Class in Salesforce
Hello Everyone,
How to Use @readOnly Annotation in Apex Class. Can anyone suggest me by sending one sample class with @readOnly Annotation.
Please let us know if we use @readOnly annotation in Apex Class that is calling from Apex Trigger.
Thanks,
Anil
You can refer the apex doc :
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_ReadOnly.htm
By default if if you are using a list on VF page, that can not hold more than 1000 records. but @readOnly increases this limit to 10,000. But you can not perform any dml operation on this list.
@Readonly annotation is used in Apex only and is used to increase the SOQL limit from 50k to million. You add the annotation over a method and the limits are relaxed for that method only. However you cannot perform any DML within it.
Readonly attribute is used in Visualforce page (readonly="true") and is only used to relax the limit of showing list records from 1,000 to 10,000.
This also prevents edits on these records.
Both are different from each other and CAN be used in different scenarios.
Please let us know if we use @readOnly annotation in Apex Class that is calling from Apex Trigger.
This is a rare scenario but you can use @Readonly on apex trigger handlers to query say 200k records, but to update them you would need to use @future and use counters to run multiple jobs updating 10k records each. I have't tried this but seems to be possible.
Please mark this as best answer.