|
Answer» These are the methods to get data from the database. The primary DIFFERENCES between get and load in Hibernate are given below: | get() | load() |
|---|
| This method GETS the data from the database as soon as it is called. | This method returns a proxy object and loads the data only when it is required. | | The database is hit every time the method is called. | The database is hit only when it is really NEEDED and this is called Lazy Loading which makes the method better. | | The method returns NULL if the object is not found. | The method throws ObjectNotFoundException if the object is not found. | | This method should be used if we are unsure about the EXISTENCE of data in the database. | This method is to be used when we know for sure that the data is present in the database. |
|