Skip to main content

Retrieving and Modifying the Values of Simple Properties

Java projections provide standard “Java Style” accessor methods, that is getPropertyName and setPropertyName methods, for retrieving and modifying the values of the simple properties of Caché objects.

For example, the following code retrieves the value of the Name property of the Contact instance referenced by contact:

String name = contact.getName();

The following code modifies, or “sets”, the value of the Name property for the contact instance. Note that the modification is not saved to the database until contact's save method executes.

contact.setName("New Name");;


Both the setPropertyName and getPropertyName methods throw checked exceptions of type CacheException.

Retrieving and modifying the values of collection properties involves slightly different techniques, which are discussed later in the tutorial.

FeedbackOpens in a new tab