openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] OpenJPA > Using Criteria API in DayTrader
Date Fri, 18 Jun 2010 16:19:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/5/_/styles/combined.css?spaceKey=openjpa&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/openjpa/Using+Criteria+API+in+DayTrader">Using
Criteria API in DayTrader</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~dianner">Dianne
Richards</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Add info and attachments for WebSphere<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" ># Click on the _Configuration&amp;nbsp;_
tab and click on _(Re)-populate DayTrader Database_ <br># Click on the _Trading &amp;
Portfolios_ tab, login, and start trading <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
<br>h2. Run DayTrader on WebSphere <br> <br>This writeup assumes some familiarity
with WebSphere. Also, the script that is provided assumes a local unmanaged node with a single
server. <br> <br>At a minimum, the WebSphere Application Server must be at version
7.0.0.9. You must also have installed the Feature Pack for OSGi Applications and Java Persistence
API 2.0. Make sure you have a profile that is augmented for JPA 2.0 function. <br> <br>Download
the following jython script. This script is used to configure the objects needed by DayTrader
(data sources, JMS queues and topics) and install the application. <br> <br>[^daytrader_singleServer.py]
<br> <br> <br>Within the bin directory of the augmented profile: <br>#
Start the server. <br># Run the script using the following command: &quot;wsadmin
\-f &lt;location of daytrader_singleServer.py&gt; &lt;script options&gt;&quot;.
You can display the list of available script options by specifying the option &quot;--help&quot;.
<br># Re-start the server. <br> <br>Run DayTrader <br># On a web browser,
go to http://localhost:&lt;application port&gt;/daytrader/ (The default application
port is 9080. But, you may have a different one if you created a new profile.) <br>#
Click on the _Configuration_ tab and click on _(Re)-create  DayTrader Database Tables and
Indexes_ <br># Click on the _Configuration&amp;nbsp;_ tab and click on _(Re)-populate
 DayTrader Database_ <br># Click on the _Trading &amp; Portfolios_ tab, login, and
start  trading <br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="UsingCriteriaAPIinDayTrader-UsingCriteriaAPIinDayTrader"></a>Using
Criteria API in DayTrader</h1>

<p>A current DayTrader project implementation in Apache Geronimo contains several JPQL
queries. These can easily be converted to JPA Criteria API queries. A sample with this conversion
can be created to run on either the Apache Geronimo server or the WebSphere Application Server
with the built-in Derby database.</p>


<h2><a name="UsingCriteriaAPIinDayTrader-DownloadingDayTrader"></a>Downloading
DayTrader</h2>

<p>You must have Subversion installed in order to download the DayTrader implementation.Subversion
can be downloaded from&nbsp;<a href="http://subversion.apache.org/packages.html" class="external-link"
rel="nofollow">http://subversion.apache.org/packages.html</a>.  Use the 2.1.3 version
of DayTrader for this sample. Follow the following steps:</p>
<ol>
	<li>Create a root directory for the download. For this example, we will use a directory
called <b>DayTrader</b>.</li>
	<li>Create subdirectories <b>branches/2.1.3</b> under the <b>DayTrader</b>
directory</li>
	<li>cd to <b>DayTrader</b></li>
	<li>Issue the following subversion command:<br/>
&nbsp;&nbsp;&nbsp;&nbsp; svn checkout <a href="https://svn.apache.org/repos/asf/geronimo/daytrader/branches/2.1.3"
class="external-link" rel="nofollow">https://svn.apache.org/repos/asf/geronimo/daytrader/branches/2.1.3</a>
branches/2.1.3</li>
</ol>


<h2><a name="UsingCriteriaAPIinDayTrader-BuildDayTrader"></a>Build DayTrader</h2>

<p>You must have maven installed in order to build DayTrader. Maven can be downloaded
from <a href="http://maven.apache.org/download.html" class="external-link" rel="nofollow">http://maven.apache.org/download.html</a>.
Unzip the file to a directory and run mvn.bat&#124;.sh in the bin subdirectory to install.
Add the bin subdirectory to you system path.</p>

<p>Maven needs a repository. Typically it is at the following:</p>
<ul>
	<li>Windows - C:\Documents and Settings\&lt;userid&gt;\.m2\repository</li>
	<li>Linux/unix - &#126;/.m2/repository</li>
</ul>


<p>From the <b>DayTrader/branches/2.1.3</b> directory, type "mvn clean install"
to build the project. (Note: If you see errors that say "java.util.zip.ZipException: error
in opening zip file", ignore them for this exercise.)</p>



<h2><a name="UsingCriteriaAPIinDayTrader-"></a></h2>

<h2><a name="UsingCriteriaAPIinDayTrader-ApplytheDayTraderPatch"></a>Apply
the DayTrader Patch</h2>

<p>The following patch can be applied using a system or downloaded <b>patch</b>
utility. (For example, you can get a patch utility for Windows from&nbsp;<a href="http://gnuwin32.sourceforge.net/packages/patch.htm"
class="external-link" rel="nofollow">http://gnuwin32.sourceforge.net/packages/patch.htm</a>.)</p>

<p>for Geronimo - <a href="/confluence/download/attachments/21791034/daytrader_geronimo.patch?version=1&amp;modificationDate=1274979220000">daytrader_geronimo.patch</a></p>









<p>for WebSphere - <a href="/confluence/download/attachments/21791034/daytrader_websphere.patch?version=1&amp;modificationDate=1276872891131">daytrader_websphere.patch</a></p>



<p>Download the appropriate patch and go to the <b>DayTrader/branches.2.1.3</b>
directory to apply it. For example, with the patch utility mentioned above, you can type:</p>

<p>patch &#45;p0 &#45;i &lt;path-to&gt;/daytrader_geronimo.patch</p>

<p>After you have applied the patch, you can see the changes from JPQL to the Criteria
API in the java class org.apache.geronimo.samples.daytrader.ejb3.TradeSLSBBean. The changes
are in the following 4 methods:</p>
<ul>
	<li>getMarketSummary()</li>
	<li>getClosedOrders()</li>
	<li>getAllQuotes()</li>
	<li>getHoldings()</li>
</ul>


<p>(Note: If you view these changes in eclipse, and you have previously run "mvn eclipse:eclipse"
to setup eclipse projects, you'll have to run this command again in order for this file to
compile.)</p>

<p>You can also <a href="/confluence/display/openjpa/Apply+an+Eclipse+Patch" title="Apply
an Eclipse Patch">Apply an Eclipse Patch</a></p>






<h2><a name="UsingCriteriaAPIinDayTrader-RecreatetheDayTraderearfile"></a>Re-create
the DayTrader ear file</h2>

<p>From the <b>DayTrader/branches/2.1.3</b> directory, type "mvn clean 
install" to build the project.</p>



<h2><a name="UsingCriteriaAPIinDayTrader-RunDayTraderonGeronimo"></a>Run
DayTrader on Geronimo</h2>

<p>This writeup assumes some familiarity with Apache Geronimo. The download and documentation
can be found at <a href="http://geronimo.apache.org/" class="external-link" rel="nofollow">http://geronimo.apache.org.</a></p>










<p>Install and start the Geronimo server</p>

<p>Add jpa2 plugins from repository <a href="http://geronimo.apache.org/plugins/openjpa2"
class="external-link" rel="nofollow">http://geronimo.apache.org/plugins/openjpa2</a>.
One way to do this is the following:</p>
<ol>
	<li>Go to the Geronimo console at http://&lt;host&gt;:8080/console and logon</li>
	<li>Select <em>plugins</em></li>
	<li>Click on <em>Add Repository</em> and add <a href="http://geronimo.apache.org/plugins/openjpa2"
class="external-link" rel="nofollow">http://geronimo.apache.org/plugins/openjpa2</a></li>
	<li>Click on <em>Update Repository List</em></li>
	<li>Make sure the new repository is selected. Then click on <em>Show Plugins
in selected repository.</em> On that panel:
	<ol>
		<li>Select <em>GeronimoPlugins, OpenJPA2::CAR 2.1.3-SNAPSHOT</em> and
<em>GeronimoPlugins, OpenJPA2::Deployer 2.1.3-SNAPSHOT</em></li>
		<li>Click on <em>Install</em></li>
	</ol>
	</li>
	<li>On the next screen, click on <em>Install</em></li>
</ol>


<p>Deploy the DayTrader application. This can be done through the console as follows:</p>
<ol>
	<li>Click on <em>Deploy New</em></li>
	<li>For <em>Archive</em>, browse to DayTrader/branches/2.1.3/modules/ear/target/daytrader-ear-2.1.3.ear</li>
	<li>For <em>Plan,</em> browse to DayTrader/branches/2.1.3/plans/dayTrader-derby-plan.xml</li>
	<li>Check <em>Start app after install</em></li>
	<li>Click on <em>Install</em></li>
</ol>


<p>Re-start the server.</p>

<p>Make sure that the system module, org.apache.geronimo.configs/axis-deployer/2.1.5/car,
is running.</p>

<p>Run DayTrader:</p>
<ol>
	<li>Go to http://&lt;host&gt;:8080/daytrader/</li>
	<li>Click on the <em>Configuration</em> tab and click on <em>(Re)-create
DayTrader Database Tables and Indexes</em></li>
	<li>Click on the <em>Configuration&nbsp;</em> tab and click on <em>(Re)-populate
DayTrader Database</em></li>
	<li>Click on the <em>Trading &amp; Portfolios</em> tab, login, and
start trading</li>
</ol>


<h2><a name="UsingCriteriaAPIinDayTrader-RunDayTraderonWebSphere"></a>Run
DayTrader on WebSphere</h2>

<p>This writeup assumes some familiarity with WebSphere. Also, the script that is provided
assumes a local unmanaged node with a single server.</p>

<p>At a minimum, the WebSphere Application Server must be at version 7.0.0.9. You must
also have installed the Feature Pack for OSGi Applications and Java Persistence API 2.0. Make
sure you have a profile that is augmented for JPA 2.0 function.</p>

<p>Download the following jython script. This script is used to configure the objects
needed by DayTrader (data sources, JMS queues and topics) and install the application.</p>

<p><a href="/confluence/download/attachments/21791034/daytrader_singleServer.py?version=1&amp;modificationDate=1276876151458">daytrader_singleServer.py</a></p>


<p>Within the bin directory of the augmented profile:</p>
<ol>
	<li>Start the server.</li>
	<li>Run the script using the following command: "wsadmin &#45;f &lt;location
of daytrader_singleServer.py&gt; &lt;script options&gt;". You can display the
list of available script options by specifying the option "--help".</li>
	<li>Re-start the server.</li>
</ol>


<p>Run DayTrader</p>
<ol>
	<li>On a web browser, go to <a href="http://localhost:" class="external-link" rel="nofollow">http://localhost:</a>&lt;application
port&gt;/daytrader/ (The default application port is 9080. But, you may have a different
one if you created a new profile.)</li>
	<li>Click on the <em>Configuration</em> tab and click on <em>(Re)-create
 DayTrader Database Tables and Indexes</em></li>
	<li>Click on the <em>Configuration&nbsp;</em> tab and click on <em>(Re)-populate
 DayTrader Database</em></li>
	<li>Click on the <em>Trading &amp; Portfolios</em> tab, login, and
start  trading</li>
</ol>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/openjpa/Using+Criteria+API+in+DayTrader">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=21791034&revisedVersion=15&originalVersion=14">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/openjpa/Using+Criteria+API+in+DayTrader?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message