Apple WebObjects 5 User Manual
Page 32

32
WebObjects Support for Enterprise-Object Instances
Apple Computer, Inc. January 2002
C H A P T E R 3
Enterprise Objects
in-memory enterprise-object instances. WebObjects has mechanisms for ensuring
the integrity of your data is maintained between your application and the
datasource without sacrificing performance or flexibility:
Validation
A good part of your application’s business logic is usually validation
(for example, verifying that customers don’t exceed their credit limits,
return dates don’t come before their corresponding check-out dates, and
so on). In your enterprise-object classes, you implement methods that
check for invalid data, and WebObjects automatically invokes them
before saving anything to the datasource.
Referential-integrity enforcement
In your model you can specify rules governing the relationships
between entities, such as whether a to-one relationship is optional or
mandatory. You can also specify delete rules—actions that must occur
when an enterprise-object instance is deleted. For example, if you have
a Department entity, you can specify that when instances of it are
deleted, all the related employees in that department are also deleted (a
cascading delete), all the employees in that department are updated to
have no department (nullify), or the department deletion is rejected if it
has any employees (deny).
Automatic primary and foreign key generation
You do not need to maintain database artifacts such as primary and
foreign key values in your application; WebObjects keeps track of them
for you. Primary and foreign keys aren’t usually meaningful parts of a
business model; rather, they’re attributes created in a relational
database to express relationships between entities. Key values can be
generated and propagated automatically.
Transaction management
Most transactions are handled for you, using the native transaction
management features of your database to group database operations
that correspond to the changes that have been made to enterprise-object
instances in memory. You don’t have to worry about beginning,
committing, or rolling back transactions unless you want to fine-tune
transaction-management behavior. WebObjects also provides a separate
in-memory transaction management feature that allows you to create
nested contexts in which a child context’s changes are folded into the
parent context only upon successful completion of an in-memory
operation.