1. session.load()
--------------------
It will always return a “proxy” (Hibernate term) without hitting the database. In Hibernate, proxy is an object with the given identifier value, its properties are not initialized yet, it just look like a temporary fake object.
If no row found , it will throws an ObjectNotFoundException.
2. session.get()
-------------------
It always hit the database and return the real object, an object that represent the database row, not proxy.
If no row found , it return null
--------------------
It will always return a “proxy” (Hibernate term) without hitting the database. In Hibernate, proxy is an object with the given identifier value, its properties are not initialized yet, it just look like a temporary fake object.
If no row found , it will throws an ObjectNotFoundException.
2. session.get()
-------------------
It always hit the database and return the real object, an object that represent the database row, not proxy.
If no row found , it return null
No comments:
Post a Comment