getHibernateTemplate().load and getHibernateTempla

Take a look at the Hibernate documentation (though I agree is not very explicit) - the HibernateTemplate is basically a wrapper around the native Hibernate API.


get() will return null if an object is not found while load() will always return a non-null object which is a proxy. If the underlying object does not exist, the proxy will thrown ObjectNotFoundException.


load() should be used when you are sure that the object exits while get() when you're not.

你可能感兴趣的:(Hibernate)