Java Reference
In-Depth Information
The PlaceOrderFacade must return to the presentation tier all of the objects
reachable from the PendingOrder except for the restaurant's opening hours and
the service area.
The PlaceOrderFacade uses the PlaceOrderFacadeResultFactory to detach the
persistent objects and create a PlaceOrderFacadeResult object returned by the
façade. As figure 7.8 shows, there are two implementations of this interface: a
Hibernate version and a JDO version.
The Hibernate version ensures that all the necessary domain objects are
loaded, and the JDO version loads the domain objects and detaches them from
the PersistenceManager . Let's look at their implementation.
7.5.1
Implementing a Hibernate result factory
The HibernatePlaceOrderFacadeResultFactory is the Hibernate implementation
of the PlaceOrderFacadeResultFactory interface. It makes sure that the Pending-
Order 's line items are loaded, and if the PendingOrder has a restaurant, it also
ensures that the restaurant's menu items are loaded.
Earlier we saw that a Hibernate application can force an object or collection to
be loaded by calling Hibernate.initialize() . However, instead of calling that
PlaceOrder
FacadeImpl
updateDeliveryInfo()
updateRestaurant()
updateQuantities()
...
<<interface>>
PlaceOrderFacadeResultFactory
make(statusCode, pendingOrder)
JDO
PlaceOrderFacade
ResultFactory
Hibernate
PlaceOrderFacade
ResultFactory
Figure 7.8
Design of the
PlaceOrderFacadeResultFactory
javax.jdo
org
.hibernate
 
 
 
 
Search WWH ::




Custom Search