Java Reference
In-Depth Information
In the
Edition
entity replace:
@ManyToMany(cascade =
{ CascadeType.MERGE, CascadeType.PERSIST,
CascadeType.REFRESH },
mappedBy = "editions")
with:
@ManyToMany(cascade =
{ CascadeType.MERGE, CascadeType.PERSIST,
CascadeType.REFRESH },
mappedBy = "editions", fetch = FetchType.EAGER)
In the
Edition
entity replace:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "edition")
with:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "edition",
fetch = FetchType.EAGER)
In the
Section
entity replace:
@OneToMany(cascade={CascadeType.ALL},mappedBy = "section")
with:
@OneToMany(cascade={CascadeType.ALL},
mappedBy = "section",fetch=FetchType.EAGER)
Also, modify the
EJB3Client.jsp
. Instead of just listing all the entities, list the
contained entities. For example, retrieve all the editions in a catalog with the
getCatalogEditions()
method:
List<Edition> editions=beanRemote.getCatalogEditions(catalog);
Similarly, retrieve all the sections in an edition with the
EditionSections
method
and all the articles in a section with the
getSectionArticles()
method. The
modified
EJB3Client.jsp
is listed next:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="model.*,java.util.*,javax.naming.*"%>
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<meta http-equiv="Content-Type"
Search WWH ::
Custom Search