Home > Object Persistency API > API Reference > Read and Update Objects
After entity creation or the execution of a query you are in possession of several entity object references. These references can be used to read or change the state of the entity or to delete it. Every attribute or navigable association is represented by a couple of methods in order to read or update entity or attribute objects respectively.
For example if your attribute is called name and is of type String, the following methods are automatically generated by OOMEGA.
public java.lang.String getName(); public void setName(java.lang.String name);
Consider an association of type Person which is called spouse and has the multiplicity constraint 0..1. Then the resulting methods are:
public Person getSpouse(); public void setSpouse(Person spouse); public OId getIdOfSpouse(); public void setIdOfSpouse(OId spouseId);
Consider an association of type Address which is called addresses and has no multiplicity constraint, i.e. a multiplicity of 0..*. Then the resulting methods are:
public Set<Address> getAddresses(); public void setAddresses(Collection<? extends Address> addresses); public SortedSet<Address> getAddresses(Comparator<? super Address> sortBy); public void addToAddresses(Address addresses); public void removeFromAddresses(Address addresses); public Set<OId> getIdsOfAddresses(); public void setIdsOfAddresses(Collection<OId> addressesIds); public void addToIdsOfAddresses(OId addressesId); public void removeFromIdsOfAddresses(OId addressesId);
The following conclusions can be drawn:
- get* and set* methods do always exist.
- Additionally addTo* and removeFrom* methods and a getter with an immediate sorting facility are generated only if the upper limit of your multiplicity constraint is greater than 1.
- ...IdOf* and ...IdsOf* methods are generated for associations and compositions but not for attributes.
The asterisk stands for the upper case attribute name or association role name. Thus, in the metamodel, attribute and role names must always be lower case. You can and should use all of these generated read and update methods in your method implementations within your metamodels. This is the way how you can interact with attributes and associations in your method implementations.
You should know about the automatic handling of bidirectional associations. There's absolutely no effort for you in order to manage the redundancy in the context of bidirectional associations. Simply call one of the update methods and related objects are transparently updated by OOMEGA.
Next chapter: Begin, Prepare, Commit and Rollback