The differences between get() and load() methods are given below.
| No. | get() | load() |
|---|---|---|
| 1) | Returns null if object is not found. | Throws ObjectNotFoundException if object is not found. |
| 2) | get() method always hit the database. | load() method doesn't hit the database. |
| 3) | It returns real object not proxy. | It returns proxy object. |
| 4) | It should be used if you are not sure about the existence of instance. | It should be used if you are sure that instance exists. |
No comments:
Post a Comment