When you use the Enterprise JavaBeansTM architecture,
data is written to and read from the database without
your writing any SQL code to do it. But what if you do not
want to store the data in a database, or want to
write your own SQL commands, or manage transactions? You can
override the built-in container-managed persistence and
implement Bean-managed persistence using your own data
storage and transaction management code.
Bean-managed persistence comes in useful when you want more
control than the container-managed persistence provides.
For example you might want to override the default of most containers
to map the data in one Bean to one row in a table, implement your own
finder
methods, or customize caching.
This chapter presents two versions of the RegistrationBean
class from Chapter 2. One version reads user data from and writes it to
a file using serialized input and output streams. The other version
provides its own SQL commands for reading from and writing to the database.
It also explains how you can write your own transaction management
code.
In a Rush?
This table links you directly to specific topics.
Topic |
Section |
Bean-Managed Persistence and the
JDBC Platform |
|
Transaction Management |
|
Bean-Managed finder Methods |
|
[TOP]