"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-6.0.0/grails-docs/src/test/resources/docs/ref/Domain Classes/load.html" (24 Jul 2023, 59553 Bytes) of package /linux/www/grails-core-6.0.0.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-6.0.0.tar.gz project site itself.

(Quick Reference)



Returns a proxy instance of the domain class for the given identifier.


// load a single instance
def b = Book.load(1)
String title = b.title

// delete an instance without retrieving it


load usually returns a proxy for the instance which is initialized on-demand, when a method other than getId() is invoked. load() only returns null if the provided id is null, so you cannot use it to test for existence. If you provide an id for an instance that doesn’t exist, a proxy will be returned and an exception will be thrown only when you call any instance method other than getId().

If there is an existing instance with the same id in the Hibernate session or 2nd-level cache, load() will return that non-proxy instance instead of a proxy.


  • id - The id of the object to retrieve