This exercise implements a MusicCD
entity bean, which represents data stored in a database describing an audio CD. The MusicCD
bean will be used by subsequent exercises.
Prerequisites
Skeleton Code
Tasks
Design a MusicCD
remote interface and a MusicCDHome
home interface. The MusicCD bean must encapsulate the persistent fields upc
, title
, artist
, type
, and price
, so the MusicCD
remote interface should define accessors and mutators for these persistent fields. The MusicCDHome
interface should define a findByPrimaryKey()
method which accepts a String
argument for the upc
, and a create()
method that accepts a upc
.
Code the MusicCDBean
entity bean implementation class. You need to provide implementations for all the methods defined in the remote interface, plus you need to implement all the methods defined in the EntityBean
interface. You also need to provide an implementation of ejbCreate()
with the same number and datatypes of arguments as you defined in the create()
method of your home interface.
Compile all the classes that compose your bean.
Package your entity bean into a jar file, using the provided XML deployment descriptor.
Where help exists, the task numbers above are linked to the
step-by-step help page.
Solution Source
The following files contain a complete implementation of the MusicCD entity bean:
Demonstration
There is no expected output for this exercise. The implementation
of this entity bean will be tested in a later exercise when this bean
is deployed, and again in the final exercise where you will write a client
that uses this bean.
Copyright 1996-2000 jGuru.com. All Rights Reserved.