1 Answer
1

This is no different from how you would do it, say you were using a RDBMS.

Let's say you are building a travel site. Now you have a database which already has the hotels that are associated with the cities that they belong to.

Now I as a user come in and request to be shown all the hotels, in, new York, then you would go to the database and query for all hotels that are in new York and then send back a list from your application, maybe rendered into a page and then display the results to the user. This results page, will at least have, the id thats in the database, and the hotel name. Now, once the user wants to see more details, say of The Waldorf hotel, they would click on that, and the I'd for that hotel would be passed back to your application. Now the code sample you have can be then used to load all the details of the hotel a Nd then display them to the user.

Make sense?

To summarize, the I'd of the record you want to load, typically comes from user input, where you load a list of Ida and the user can then select one or more. And to get the list of Ida, you typically query by some parameters, in the above case, by the city name.

Now, to proceed with using the sample above, you can hard code the id, to a value that you already have in the db and complete the code.

Another option, you can create a new instance of the hotel object and then issue the ave command like the docs say and then once you do that, if you have a property mapped as an ID, you can do a get on that property and then pass it along to the the note I'd, and then execute the read query.