ÿþ<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=unicode" /> <meta http-equiv="Content-Language" content="en-us" /> <style> <!-- p.MsoNormal, li.MsoNormal {margin-top:0mm; margin-right:0mm; margin-bottom:10.0pt; margin-left:0mm; line-height:115%; font-size:12.0pt; font-family:"Times New Roman","serif";} h1 {margin-right:0mm; margin-left:0mm; font-size:24.0pt; font-family:"Times New Roman","serif"; font-weight:bold} a:link {color:blue; text-decoration:underline;} a:visited {color:purple; text-decoration:underline;} p {margin-right:0mm; margin-left:0mm; font-size:12.0pt; font-family:"Times New Roman","serif";} ol {margin-bottom:0mm;} --> </style> <title>Adding Additional Helper Methods to the Hibernate web applications </title> <meta name="keywords" content="Java, opensource, Hibernate, framework, technology, applications, programs, examples, samples, IDE, NetBeans, database" /> <meta name="description" content="A detail steps on how to add additional helper methods for the Java Hibernate in web applications" /> </head> <body lang="EN-US" link="#0000FF" vlink="#800080" topmargin="20" leftmargin="20" rightmargin="20" bottommargin="20"> <div class="WordSection1"> <h1 align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><b> <font size="6" face="Arial"><span style="font-weight:bold">Using Hibernate in a Web Application 5</span></font></b></h1> <h1 align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><b> <font size="5" face="Arial"> <span style="font-weight:bold; font-style:italic">(With NetBeans &amp; MySQL)</span></font></b></h1> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0" align="center"><script src="http://tag.contextweb.com/TagPublish/getjs.aspx?action=VIEWAD&cwrun=200&cwadformat=728X90&cwpid=527221&cwwidth=728&cwheight=90&cwpnet=1&cwtagid=85440"></script></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><b><font size="3" face="Arial"> <span style="font-size:12.0pt;font-weight:bold">Adding Additional Helper Methods</span></font></b></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">You will now add additional helper methods that create queries based on an input variable. You can check the queries in the HQL query editor.</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="1" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Add the following method to retrieve a list of categories according to </span></font> <font face="Courier New"><span style="font-family:&quot;Arial&quot;">filmId</span></font><font face="Arial">.</font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700"> public Category getCategoryByID(int filmId){</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; List&lt;Category&gt; categoryList = null;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; try {</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; org.hibernate.Transaction tx = session.beginTransaction();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Query q = session.createQuery(&quot;from Category as category where category.categoryId in (select filmCat.category.categoryId from FilmCategory as filmCat where filmCat.film.filmId=&#39;&quot; + filmId + &quot;&#39;)&quot;);</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; categoryList = (List&lt;Category&gt;) q.list();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; } catch (Exception e) {</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; }</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; return categoryList.get(0);</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700"> }</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="630" height="312" src="hibernateormnetbean_files/javahibernateormdbaseweb048.png" alt="Adding additional helper methods that create queries based on an input variable" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="2" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Add the following method to retrieve a single film according to </span></font> <font face="Courier New"><span style="font-family:&quot;Arial&quot;">filmId</span></font><font face="Arial">.</font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700"> public Film getFilmByID(int filmId){</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; Film film = null;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; try {</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; org.hibernate.Transaction tx = session.beginTransaction();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Query q = session.createQuery(&quot;from Film as film where film.filmId=&quot; + filmId);</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; film = (Film) q.uniqueResult();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; } catch (Exception e) {</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; }</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; return film;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700"> }</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="759" height="331" src="hibernateormnetbean_files/javahibernateormdbaseweb049.png" alt="Adding additional helper methods that create queries based on an input variable" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="3" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Add the following method to retrieve the film language according to </span></font> <font face="Courier New"><span style="font-family:&quot;Arial&quot;">langId</span></font><font face="Arial">.</font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700"> public String getLangByID(int langId){</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; Language language = null;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; try {</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; org.hibernate.Transaction tx = session.beginTransaction();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Query q = session.createQuery(&quot;from Language as lang where lang.languageId=&quot; + langId);</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; language = (Language) q.uniqueResult();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; } catch (Exception e) {</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; }</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; return language.getName();</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700"> }</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="598" height="332" src="hibernateormnetbean_files/javahibernateormdbaseweb050.png" alt="Adding method to retrieve the film language according to langId" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><b><font size="3" face="Arial"> <span style="font-size:12.0pt; font-weight:bold">Creating the JSF Managed Bean</span></font></b></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">In this exercise you will create a JSF managed bean. The methods in the managed bean are used for displaying data in the JSF pages and for accessing methods in the helper class to retrieve records. The JSF 2.0 specification enables you to use annotations in a bean class to identify the class as a JSF managed bean, to specify the scope and to specify a name for the bean.</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">To create the managed bean, perform the following steps.</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="1" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Right-click the </span></font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">dvdrental</span></font><font face="Arial"> source package node and choose New &gt; Other.</font></p> </li> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Select JSF Managed Bean from the JavaServer Faces category. Click Next.</span></font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="676" height="485" src="hibernateormnetbean_files/javahibernateormdbaseweb051.png" alt="Adding new JSF managed bean to the Java web application" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="3" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Type <b> <span style="font-weight:bold">FilmController</span></b> for the Class Name. </span></font></p> </li> </ol> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:36.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Arial"><span style="font-size:12.0pt">You will use the Managed Bean name </span></font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">filmController</span></font><font face="Arial"> as the value for the </font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">inputText</span></font><font face="Arial"> and </font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">commandButton</span></font><font face="Arial"> in the JSF page </font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">index.xhtml</span></font><font face="Arial"> when calling methods in the bean.</font></p> <ol style="margin-top:0mm" start="4" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Select <b> <span style="font-weight:bold">dvdrental</span></b> for the Package.</span></font></p> </li> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Type <b> <span style="font-weight:bold">filmController</span></b> for the Name that will be used for the managed bean.</span></font></p> </li> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Set Scope to Session. Click Finish.</span></font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="567" height="484" src="hibernateormnetbean_files/javahibernateormdbaseweb052.png" alt="Doing some settings for new JSF managed bean" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">When you click Finish, the IDE creates the bean class and opens the class in the editor. The IDE added the </span></font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">@ManagedBean</span></font><font face="Arial"> and </font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">@SessionScoped</span></font><font face="Arial"> annotations and the name of the bean.</font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">@ManagedBean(name=&quot;filmController&quot;)</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">@SessionScoped</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">public class FilmController {</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; /** Creates a new instance of FilmController */</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; public FilmController() {</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">&nbsp;&nbsp;&nbsp; }</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">}</span></font></p> </blockquote> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="1" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Add the following fields (in bold) to the class.</span></font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;">@ManagedBean(name=&quot;filmController&quot;)</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;">@SessionScoped</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;">public class FilmController {</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;">&nbsp;&nbsp;&nbsp; <b><span style="font-weight:bold">int startId;</span></b></span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; int endId;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; DataModel filmTitles;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; FilmHelper helper;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; private int recordCount = 1000;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; private int pageSize = 10;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; private Film current;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; private int selectedItemIndex;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;">}</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="441" height="301" src="hibernateormnetbean_files/javahibernateormdbaseweb053.png" alt="The IDE added the @ManagedBean and @SessionScoped annotations and the name of the bean" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">Fix your imports (Ctrl-Shift-I) and save your changes.</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0" align="center"><script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; /* 300x250, created 5/16/08javaos */ google_ad_slot = "8146009330"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0" align="center"><font face="Arial"> ---------------------------------------------------------------------</font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="339" height="288" src="hibernateormnetbean_files/javahibernateormdbaseweb054.png" alt="Fixing more import errors" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="2" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Add the following code (in bold) to create the FilmController instance and retrieve the films.</span></font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;">/** Creates a new instance of FilmController */</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;">public FilmController() {</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;">&nbsp;&nbsp;&nbsp; <b><span style="font-weight:bold">helper = new FilmHelper();</span></b></span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; startId = 1;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; endId = 10;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public FilmController(int startId, int endId) {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; helper = new FilmHelper();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; this.startId = startId;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; this.endId = endId;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public Film getSelected() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; if (current == null) {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; current = new Film();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selectedItemIndex = -1;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; }</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; return current;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public DataModel getFilmTitles() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; if (filmTitles == null) {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filmTitles = new ListDataModel(helper.getFilmTitles(startId, endId));</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; }</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; return filmTitles;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">void recreateModel() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; filmTitles = null;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="681" height="400" src="hibernateormnetbean_files/javahibernateormdbaseweb055.png" alt="Adding code to create the FilmController instance and retrieve the films" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">Fix your imports (Ctrl-Shift-I) and save your changes.</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="529" height="219" src="hibernateormnetbean_files/javahibernateormdbaseweb056.png" alt="Again, fixing unresolved imports" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="3" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Add the following methods that are used to display the table and navigate the pages.</span></font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public boolean isHasNextPage() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">if (endId + pageSize &lt;= recordCount) {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:99.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return true;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return false;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public boolean isHasPreviousPage() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">if (startId-pageSize &gt; 0) {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:99.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return true;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return false;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public String next() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">startId = endId+1;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">endId = endId + pageSize;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">recreateModel();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return &quot;index&quot;;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public String previous() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">startId = startId - pageSize;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">endId = endId - pageSize;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">recreateModel();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return &quot;index&quot;;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public int getPageSize() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return pageSize;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public String prepareView(){</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">current = (Film) getFilmTitles().getRowData();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return &quot;browse&quot;;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">public String prepareList(){</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">recreateModel();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:54.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">return &quot;index&quot;;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">}</span></font></b></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="469" height="500" src="hibernateormnetbean_files/javahibernateormdbaseweb057.png" alt="Adding the methods that are used to display the table and navigate the pages" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:36.0pt;margin-bottom:0;line-height:100%"> <font size="3" face="Arial"><span style="font-size:12.0pt">The methods that return &quot;index&quot; or &quot;browse&quot; will prompt the JSF navigation handler to try to open a page named </span></font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">index.xhtml</span></font><font face="Arial"> or </font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">browse.xhtml</span></font><font face="Arial">. The JSF 2.0 specification enables the use of implicit navigation rules in applications that use Facelets technology. In this application, no navigation rules are configured in </font><font face="Courier New"> <span style="font-family:&quot;Arial&quot;">faces-config.xml</span></font><font face="Arial">. Instead, the navigation handler will try to locate a suitable page in the application.</font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <ol style="margin-top:0mm" start="4" type="1"> <li class="MsoNormal" style="margin-bottom:0mm;margin-bottom:.0001pt;line-height: normal"> <p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size:12.0pt">Add the following methods that access the helper class to retrieve additional film details.</span></font></p> </li> </ol> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><b><font size="3" face="Arial"> <span style="font-size:12.0pt; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; public String getLanguage() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int langID = current.getLanguageByLanguageId().getLanguageId().intValue();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String language = helper.getLangByID(langID);</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return language;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; }</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; public String getActors() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List actors = helper.getActorsByID(current.getFilmId());</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringBuffer totalCast = new StringBuffer();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; actors.size(); i++) {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Actor actor = (Actor) actors.get(i);</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; totalCast.append(actor.getFirstName());</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; totalCast.append(&quot; &quot;);</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; totalCast.append(actor.getLastName());</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; totalCast.append(&quot;&nbsp; &quot;);</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return totalCast.toString();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; }</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; public String getCategory() {</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Category category = helper.getCategoryByID(current.getFilmId());</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return category.getName();</span></font></b></p> <p class="MsoNormal" style="margin-top:0;margin-right:0mm;margin-bottom:0mm; margin-left:18.0pt;margin-bottom:0;line-height:100%"><b> <font size="3" face="Courier New"> <span style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:bold">&nbsp;&nbsp;&nbsp; }</span></font></b></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="694" height="496" src="hibernateormnetbean_files/javahibernateormdbaseweb058.png" alt="Adding methods that access the helper class to retrieve additional film details" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">Fix your imports (Ctrl-Shift-I) and save your changes.</span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="337" height="317" src="hibernateormnetbean_files/javahibernateormdbaseweb059.png" alt="Again, fixing more unresolved imports" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0"><font size="3" face="Arial"><span style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="margin-bottom:0mm;margin-bottom:0; text-align:center;line-height:100%; margin-top:0"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="500" height="200" src="hibernateormnetbean_files/javahibernateormdbaseweb060.png" alt="Fixing the java.util.List import" /></span></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0" align="center">&nbsp;<script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; /* 728x15, created 5/16/08javaos */ google_ad_slot = "3545464564"; google_ad_width = 728; google_ad_height = 15; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></p> <hr color="#FF0000" /> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0; line-height:100%; margin-top:0" align="center"> <font face="Arial" size="5"> <a title="Creating the HibernateUtil.java Helper File" target="_top" href="http://www.visualcplusdotnet.com/javaopensource/hibernateormnetbean3.html"> Java, ORM &amp; Hibernate 4</a> | <a title="The Java and open source applications" target="_top" href="http://www.javaguicodexample.com/"> Back to Main</a> | <a title="Creating the Web Pages" target="_top" href="http://www.visualcplusdotnet.com/javaopensource/hibernateormnetbean5.html"> Java, ORM &amp; Hibernate 6</a></font></p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0">&nbsp;</p> <p class="MsoNormal" style="margin-bottom:0mm;margin-bottom:0;line-height: 100%; margin-top:0" align="center"><script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; /* 728x90, created 5/16/08 javaos */ google_ad_slot = "1917524460"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></p> </div> </body> </html>