Java Reference
In-Depth Information
Figure 9.3. The ActionBazaar domain model complete with entities and relationships. Entities are related to one
another and the relationship can be one-to-one, one-to-many, many-to-one, or many-to-many. Relationships can
be either uni- or bidirectional.
Figure 9.3 is pretty self-explanatory. For example, an item is sold by a seller, a seller may
sell more than one item, the item is in one or more categories, each category may have a
parent category, a bidder places a bid on an item, and so on. You should also note that al-
though the domain model describes the possibilities for putting objects together, it doesn't
describe the way in which the objects are manipulated. For instance, although you can see
that an order consists of one or more items and is placed by a bidder, you're not told how
or when these relationships are formed. By applying a bit of common sense, it's easy to
figure out that an item won through a winning bid is put into an order placed by the highest
bidder. These relationships are probably formed by the business rules after the bidding is
over and the winner checks out the item won. Next, we'll take a look at how this domain
model may be turned into Java classes.
Domain objects as Java classes
Now let's get your feet wet by examining some JPA code. But before we get to JPA, we'll
look at an ordinary POJO for the relatively complex domain object, Category . Listing
9.1 describes what the Category class will look like. You'll notice at this point that it's
 
Search WWH ::




Custom Search