diff --git a/4146.pdf b/4146.pdf
new file mode 100644
index 0000000..e0accdd
Binary files /dev/null and b/4146.pdf differ
diff --git a/4147.pdf b/4147.pdf
new file mode 100644
index 0000000..8eefa3b
Binary files /dev/null and b/4147.pdf differ
diff --git a/9781430209638.jpg b/9781430209638.jpg
new file mode 100644
index 0000000..711968d
Binary files /dev/null and b/9781430209638.jpg differ
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..654113f
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,27 @@
+Freeware License, some rights reserved
+
+Copyright (c) 2008 Yuli Vasiliev
+
+Permission is hereby granted, free of charge, to anyone obtaining a copy
+of this software and associated documentation files (the "Software"),
+to work with the Software within the limits of freeware distribution and fair use.
+This includes the rights to use, copy, and modify the Software for personal use.
+Users are also allowed and encouraged to submit corrections and modifications
+to the Software for the benefit of other users.
+
+It is not allowed to reuse, modify, or redistribute the Software for
+commercial use in any way, or for a user’s educational materials such as books
+or blog articles without prior permission from the copyright holder.
+
+The above copyright notice and this permission notice need to be included
+in all copies or substantial portions of the software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d3f5aad
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+#Apress Source Code
+
+This repository accompanies [*Beginning Database-Driven Application Development in Java EE*](http://www.apress.com/9781430209638) by Yuli Vasiliev (Apress, 2008).
+
+![Cover image](9781430209638.jpg)
+
+Download the files as a zip using the green button, or clone the repository to your machine using Git.
+
+##Releases
+
+Release v1.0 corresponds to the code in the published book, without corrections or updates.
+
+##Contributions
+
+See the file Contributing.md for more information on how you can contribute to this repository.
diff --git a/ch1/HelloWorld/WEB-INF/sun-web.xml b/ch1/HelloWorld/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..1bee796
--- /dev/null
+++ b/ch1/HelloWorld/WEB-INF/sun-web.xml
@@ -0,0 +1,5 @@
+
+
+
+ /HelloWorld
+
\ No newline at end of file
diff --git a/ch1/HelloWorld/WEB-INF/web.xml b/ch1/HelloWorld/WEB-INF/web.xml
new file mode 100644
index 0000000..58000ac
--- /dev/null
+++ b/ch1/HelloWorld/WEB-INF/web.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ index.jsp
+
+
+
\ No newline at end of file
diff --git a/ch1/HelloWorld/helloworld.war b/ch1/HelloWorld/helloworld.war
new file mode 100644
index 0000000..01b7405
Binary files /dev/null and b/ch1/HelloWorld/helloworld.war differ
diff --git a/ch1/HelloWorld/index.jsp b/ch1/HelloWorld/index.jsp
new file mode 100644
index 0000000..ae10708
--- /dev/null
+++ b/ch1/HelloWorld/index.jsp
@@ -0,0 +1,10 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+
+
+ Hello World Page
+
+
+
Hello World!
+
+
\ No newline at end of file
diff --git a/ch1/HelloWorldWithIDE/build.xml b/ch1/HelloWorldWithIDE/build.xml
new file mode 100644
index 0000000..acf7f80
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/build.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+ Builds, tests, and runs the project HelloWorldWithIDE.
+
+
+
diff --git a/ch1/HelloWorldWithIDE/build/web/META-INF/MANIFEST.MF b/ch1/HelloWorldWithIDE/build/web/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..59499bc
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/build/web/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/ch1/HelloWorldWithIDE/build/web/WEB-INF/sun-web.xml b/ch1/HelloWorldWithIDE/build/web/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..0c5f373
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/build/web/WEB-INF/sun-web.xml
@@ -0,0 +1,14 @@
+
+
+
+ /HelloWorldWithIDE
+
+
+
+ Enable debug info compilation in the generated servlet class
+
+
+ Maintain a one-to-one correspondence between static content and the generated servlet class' java code
+
+
+
diff --git a/ch1/HelloWorldWithIDE/build/web/WEB-INF/web.xml b/ch1/HelloWorldWithIDE/build/web/WEB-INF/web.xml
new file mode 100644
index 0000000..b6f2242
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/build/web/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+ 30
+
+
+
+
+ index.jsp
+
+
+
diff --git a/ch1/HelloWorldWithIDE/build/web/index.jsp b/ch1/HelloWorldWithIDE/build/web/index.jsp
new file mode 100644
index 0000000..7f75098
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/build/web/index.jsp
@@ -0,0 +1,36 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%--
+The taglib directive below imports the JSTL library. If you uncomment it,
+you must also add the JSTL library to the project. The Add Library... action
+on Libraries node in Projects view can be used to add the JSTL 1.1 library.
+--%>
+<%--
+<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+--%>
+
+
+
+
+
+
+ JSP Page
+
+
+
+
Hello World!!!
+
+ <%--
+ This example uses JSTL, uncomment the taglib directive above.
+ To test, display the page like this: index.jsp?sayHello=true&name=Murphy
+ --%>
+ <%--
+
+
+ Hello ${param.name}!
+
+ --%>
+
+
+
diff --git a/ch1/HelloWorldWithIDE/dist/HelloWorldWithIDE.war b/ch1/HelloWorldWithIDE/dist/HelloWorldWithIDE.war
new file mode 100644
index 0000000..79af749
Binary files /dev/null and b/ch1/HelloWorldWithIDE/dist/HelloWorldWithIDE.war differ
diff --git a/ch1/HelloWorldWithIDE/nbproject/ant-deploy.xml b/ch1/HelloWorldWithIDE/nbproject/ant-deploy.xml
new file mode 100644
index 0000000..7ec8e30
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/nbproject/ant-deploy.xml
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${lefty}?xml version="1.0" encoding="UTF-8"?${righty}
+${lefty}!DOCTYPE resources PUBLIC
+ "-//Sun Microsystems Inc.//DTD Application Server 9.0 Resource Definitions //EN"
+ "${sjsas.root}/lib/dtds/sun-resources_1_2.dtd"${righty}
+${lefty}resources${righty}
+${lefty}/resources${righty}
+
+
+
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+
+
+ ]]>
+
+
+
+
+
+
+
+ ]]>
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ch1/HelloWorldWithIDE/nbproject/build-impl.xml b/ch1/HelloWorldWithIDE/nbproject/build-impl.xml
new file mode 100644
index 0000000..e53e06c
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/nbproject/build-impl.xml
@@ -0,0 +1,690 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set build.web.dir
+ Must set build.generated.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.war
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.jsp.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select a file in the IDE or set jsp.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable.
+
+
+ Launching ${browse.url}
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ch1/HelloWorldWithIDE/nbproject/genfiles.properties b/ch1/HelloWorldWithIDE/nbproject/genfiles.properties
new file mode 100644
index 0000000..8b4171a
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=cf13b54c
+build.xml.script.CRC32=d0e6b3e4
+build.xml.stylesheet.CRC32=95be3570
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=cf13b54c
+nbproject/build-impl.xml.script.CRC32=fce1b4c1
+nbproject/build-impl.xml.stylesheet.CRC32=385ea7e4
diff --git a/ch1/HelloWorldWithIDE/nbproject/private/private.properties b/ch1/HelloWorldWithIDE/nbproject/private/private.properties
new file mode 100644
index 0000000..640ece8
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/nbproject/private/private.properties
@@ -0,0 +1,10 @@
+deploy.ant.properties.file=D:\\Documents and Settings\\Administrator\\.netbeans\\5.5.1\\glassfish_1.properties
+j2ee.platform.classpath=C:\\glassfish\\lib\\javaee.jar:C:\\glassfish\\lib\\jsf-impl.jar:C:\\glassfish\\lib\\activation.jar:C:\\glassfish\\lib\\appserv-tags.jar:C:\\glassfish\\lib\\mail.jar:C:\\glassfish\\lib\\appserv-jstl.jar:C:\\glassfish\\lib\\webservices-tools.jar:C:\\glassfish\\lib\\webservices-rt.jar:C:\\glassfish\\lib\\appserv-ws.jar
+j2ee.platform.is.jsr109=true
+j2ee.platform.wscompile.classpath=C:\\glassfish\\lib\\j2ee.jar:C:\\glassfish\\lib\\saaj-api.jar:C:\\glassfish\\lib\\saaj-impl.jar:C:\\glassfish\\lib\\jaxrpc-api.jar:C:\\glassfish\\lib\\jaxrpc-impl.jar:C:\\glassfish\\lib\\endorsed\\jaxp-api.jar:C:\\glassfish\\lib\\appserv-ws.jar:C:\\glassfish\\lib\\webservices-tools.jar:C:\\glassfish\\lib\\webservices-rt.jar
+j2ee.platform.wsgen.classpath=C:\\glassfish\\lib\\webservices-tools.jar:C:\\glassfish\\lib\\webservices-rt.jar:C:\\glassfish\\lib\\tools.jar:C:\\glassfish\\lib\\appserv-jstl.jar:C:\\glassfish\\lib\\javaee.jar:C:\\glassfish\\lib\\appserv-ws.jar:C:\\glassfish\\lib\\mail.jar:C:\\glassfish\\lib\\activation.jar
+j2ee.platform.wsimport.classpath=C:\\glassfish\\lib\\webservices-tools.jar:C:\\glassfish\\lib\\webservices-rt.jar:C:\\glassfish\\lib\\tools.jar:C:\\glassfish\\lib\\appserv-jstl.jar:C:\\glassfish\\lib\\javaee.jar:C:\\glassfish\\lib\\appserv-ws.jar:C:\\glassfish\\lib\\mail.jar:C:\\glassfish\\lib\\activation.jar
+j2ee.platform.wsit.classpath=
+j2ee.server.instance=[C:\\glassfish]deployer:Sun:AppServer::localhost:4848
+jaxws.endorsed.dir=C:\\netbeans-5.5.1\\ide7\\modules\\ext\\jaxws21\\api
+user.properties.file=D:\\Documents and Settings\\Administrator\\.netbeans\\5.5.1\\build.properties
diff --git a/ch1/HelloWorldWithIDE/nbproject/private/private.xml b/ch1/HelloWorldWithIDE/nbproject/private/private.xml
new file mode 100644
index 0000000..c1f155a
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/nbproject/private/private.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/ch1/HelloWorldWithIDE/nbproject/project.properties b/ch1/HelloWorldWithIDE/nbproject/project.properties
new file mode 100644
index 0000000..0537049
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/nbproject/project.properties
@@ -0,0 +1,66 @@
+build.classes.dir=${build.web.dir}/WEB-INF/classes
+build.classes.excludes=**/*.java,**/*.form
+build.dir=build
+build.ear.classes.dir=${build.ear.web.dir}/WEB-INF/classes
+build.ear.web.dir=${build.dir}/ear-module
+build.generated.dir=${build.dir}/generated
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+build.web.dir=${build.dir}/web
+build.web.excludes=${build.classes.excludes}
+client.urlPart=
+compile.jsps=false
+conf.dir=${source.root}/conf
+debug.classpath=${javac.classpath}:${build.classes.dir}:${build.ear.classes.dir}
+debug.test.classpath=\
+ ${run.test.classpath}
+display.browser=true
+dist.dir=dist
+dist.ear.war=${dist.dir}/${war.ear.name}
+dist.javadoc.dir=${dist.dir}/javadoc
+dist.war=${dist.dir}/${war.name}
+j2ee.platform=1.5
+j2ee.server.type=J2EE
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.debug=true
+javac.deprecation=false
+javac.source=1.5
+javac.target=1.5
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${libs.junit.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.preview=true
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+jspcompilation.classpath=${jspc.classpath}:${javac.classpath}
+lib.dir=${web.docbase.dir}/WEB-INF/lib
+no.dependencies=false
+platform.active=default_platform
+resource.dir=setup
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+# Space-separated list of JVM arguments used when running class with main method
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
+runmain.jvmargs=
+source.root=src
+src.dir=${source.root}/java
+test.src.dir=test
+war.content.additional=
+war.ear.name=HelloWorldWithIDE.war
+war.name=HelloWorldWithIDE.war
+war.package=true
+web.docbase.dir=web
diff --git a/ch1/HelloWorldWithIDE/nbproject/project.xml b/ch1/HelloWorldWithIDE/nbproject/project.xml
new file mode 100644
index 0000000..458abec
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/nbproject/project.xml
@@ -0,0 +1,18 @@
+
+
+ org.netbeans.modules.web.project
+
+
+ HelloWorldWithIDE
+ 1.6
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ch1/HelloWorldWithIDE/src/conf/MANIFEST.MF b/ch1/HelloWorldWithIDE/src/conf/MANIFEST.MF
new file mode 100644
index 0000000..59499bc
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/src/conf/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/ch1/HelloWorldWithIDE/web/WEB-INF/sun-web.xml b/ch1/HelloWorldWithIDE/web/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..0c5f373
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/web/WEB-INF/sun-web.xml
@@ -0,0 +1,14 @@
+
+
+
+ /HelloWorldWithIDE
+
+
+
+ Enable debug info compilation in the generated servlet class
+
+
+ Maintain a one-to-one correspondence between static content and the generated servlet class' java code
+
+
+
diff --git a/ch1/HelloWorldWithIDE/web/WEB-INF/web.xml b/ch1/HelloWorldWithIDE/web/WEB-INF/web.xml
new file mode 100644
index 0000000..b6f2242
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/web/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+ 30
+
+
+
+
+ index.jsp
+
+
+
diff --git a/ch1/HelloWorldWithIDE/web/index.jsp b/ch1/HelloWorldWithIDE/web/index.jsp
new file mode 100644
index 0000000..0eef11f
--- /dev/null
+++ b/ch1/HelloWorldWithIDE/web/index.jsp
@@ -0,0 +1,28 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+
+
+
+
+
+
+ JSP Page
+
+
+
+
Please enter a user name or password that is authorized to access this application. For this application, this means a user has been created in the file realm and has been assigned to the group of user. Click here to Try Again
+
+
+
diff --git a/ch15/sampleapp/webtarget/showcart.jsp b/ch15/sampleapp/webtarget/showcart.jsp
new file mode 100644
index 0000000..b3932c1
--- /dev/null
+++ b/ch15/sampleapp/webtarget/showcart.jsp
@@ -0,0 +1,42 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+
+
+
+
+
Your shopping cart items to buy now
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ch15/sampleapp/webtarget/stylesheet.css b/ch15/sampleapp/webtarget/stylesheet.css
new file mode 100644
index 0000000..ee758ed
--- /dev/null
+++ b/ch15/sampleapp/webtarget/stylesheet.css
@@ -0,0 +1,21 @@
+.header {
+text-align: center;
+font-family: arial;
+font-style: bold;
+color: Black;
+background: seashell;
+padding: 10px;
+}
+.evenCol {
+text-align: center;
+font-family: arial;
+font-size: 10pt;
+background: Snow;
+
+}
+.oddCol {
+text-align: center;
+font-family: arial;
+font-size: 10pt;
+background: whitesmoke;
+}
diff --git a/ch2/EJBJPAProject/AppClient/dist/appclient.jar b/ch2/EJBJPAProject/AppClient/dist/appclient.jar
new file mode 100644
index 0000000..3231f81
Binary files /dev/null and b/ch2/EJBJPAProject/AppClient/dist/appclient.jar differ
diff --git a/ch2/EJBJPAProject/AppClient/src/ejbjpa/client/EmployeeSessionClient.java b/ch2/EJBJPAProject/AppClient/src/ejbjpa/client/EmployeeSessionClient.java
new file mode 100644
index 0000000..6289764
--- /dev/null
+++ b/ch2/EJBJPAProject/AppClient/src/ejbjpa/client/EmployeeSessionClient.java
@@ -0,0 +1,12 @@
+package ejbjpa.client;
+
+import javax.ejb.EJB;
+import ejbjpa.ejb.EmployeeSession;
+public class EmployeeSessionClient {
+ @EJB
+ private static EmployeeSession employeeSession;
+ public static void main (String[] args)
+ {
+ System.out.println(employeeSession.getEmplastname(10));
+ }
+}
\ No newline at end of file
diff --git a/ch2/EJBJPAProject/AppClient/target/META-INF/MANIFEST.MF b/ch2/EJBJPAProject/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..1ca0c90
--- /dev/null
+++ b/ch2/EJBJPAProject/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.EmployeeSessionClient
+
diff --git a/ch2/EJBJPAProject/AppClient/target/ejbjpa/client/EmployeeSessionClient.class b/ch2/EJBJPAProject/AppClient/target/ejbjpa/client/EmployeeSessionClient.class
new file mode 100644
index 0000000..c2d633b
Binary files /dev/null and b/ch2/EJBJPAProject/AppClient/target/ejbjpa/client/EmployeeSessionClient.class differ
diff --git a/ch2/EJBJPAProject/EJBJPA/dist/ejbjpa.jar b/ch2/EJBJPAProject/EJBJPA/dist/ejbjpa.jar
new file mode 100644
index 0000000..177ad5a
Binary files /dev/null and b/ch2/EJBJPAProject/EJBJPA/dist/ejbjpa.jar differ
diff --git a/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/ejb/EmployeeSession.java b/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/ejb/EmployeeSession.java
new file mode 100644
index 0000000..74842a9
--- /dev/null
+++ b/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/ejb/EmployeeSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface EmployeeSession {
+ public String getEmplastname(Integer empno);
+}
diff --git a/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/ejb/EmployeeSessionBean.java b/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/ejb/EmployeeSessionBean.java
new file mode 100644
index 0000000..5124761
--- /dev/null
+++ b/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/ejb/EmployeeSessionBean.java
@@ -0,0 +1,25 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class EmployeeSessionBean implements EmployeeSession {
+ @PersistenceUnit(unitName = "ejbjpa-pu")
+ private EntityManagerFactory emf;
+ public String getEmplastname(Integer empno) {
+ String fullname;
+ try {
+ EntityManager em = emf.createEntityManager();
+ Employee emp = em.find(Employee.class, empno);
+ fullname = emp.getFirstname()+" "+emp.getLastname();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return fullname;
+ }
+}
\ No newline at end of file
diff --git a/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/entities/Employee.java b/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/entities/Employee.java
new file mode 100644
index 0000000..26690f8
--- /dev/null
+++ b/ch2/EJBJPAProject/EJBJPA/src/ejbjpa/entities/Employee.java
@@ -0,0 +1,37 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+@Entity
+@Table(name = "EMPLOYEES")
+public class Employee implements Serializable {
+ @Id
+ @Column(name = "EMPNO")
+ private Integer empno;
+ @Column(name = "FIRSTNAME", nullable = false)
+ private String firstname;
+ @Column(name = "LASTNAME", nullable = false)
+ private String lastname;
+ public Employee() {
+ }
+ public Integer getEmpno() {
+ return this.empno;
+ }
+ public void setEmpno(Integer empno) {
+ this.empno = empno;
+ }
+ public String getFirstname() {
+ return this.firstname;
+ }
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+ public String getLastname() {
+ return this.lastname;
+ }
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+}
diff --git a/ch2/EJBJPAProject/EJBJPA/target/META-INF/persistence.xml b/ch2/EJBJPAProject/EJBJPA/target/META-INF/persistence.xml
new file mode 100644
index 0000000..2786fc8
--- /dev/null
+++ b/ch2/EJBJPAProject/EJBJPA/target/META-INF/persistence.xml
@@ -0,0 +1,7 @@
+
+
+
+ jdbc/myderbypool
+ejbjpa.entities.Employee
+
+
diff --git a/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/ejb/EmployeeSession.class b/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/ejb/EmployeeSession.class
new file mode 100644
index 0000000..368a5c9
Binary files /dev/null and b/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/ejb/EmployeeSession.class differ
diff --git a/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/ejb/EmployeeSessionBean.class b/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/ejb/EmployeeSessionBean.class
new file mode 100644
index 0000000..c8adcc9
Binary files /dev/null and b/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/ejb/EmployeeSessionBean.class differ
diff --git a/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/entities/Employee.class b/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/entities/Employee.class
new file mode 100644
index 0000000..973c7d4
Binary files /dev/null and b/ch2/EJBJPAProject/EJBJPA/target/ejbjpa/entities/Employee.class differ
diff --git a/ch2/EJBJPAProject/dist/ejbjpaapp.jar b/ch2/EJBJPAProject/dist/ejbjpaapp.jar
new file mode 100644
index 0000000..1e08a51
Binary files /dev/null and b/ch2/EJBJPAProject/dist/ejbjpaapp.jar differ
diff --git a/ch2/EJBJPAProject/target/META-INF/application.xml b/ch2/EJBJPAProject/target/META-INF/application.xml
new file mode 100644
index 0000000..b1784cd
--- /dev/null
+++ b/ch2/EJBJPAProject/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ ejbjpa
+
+ ejbjpa.jar
+
+
+ appclient.jar
+
+
diff --git a/ch2/EJBJPAProject/target/appclient.jar b/ch2/EJBJPAProject/target/appclient.jar
new file mode 100644
index 0000000..3231f81
Binary files /dev/null and b/ch2/EJBJPAProject/target/appclient.jar differ
diff --git a/ch2/EJBJPAProject/target/ejbjpa.jar b/ch2/EJBJPAProject/target/ejbjpa.jar
new file mode 100644
index 0000000..177ad5a
Binary files /dev/null and b/ch2/EJBJPAProject/target/ejbjpa.jar differ
diff --git a/ch2/HelloWorldProject/HelloWorldClient/dist/helloworldclient.jar b/ch2/HelloWorldProject/HelloWorldClient/dist/helloworldclient.jar
new file mode 100644
index 0000000..686c734
Binary files /dev/null and b/ch2/HelloWorldProject/HelloWorldClient/dist/helloworldclient.jar differ
diff --git a/ch2/HelloWorldProject/HelloWorldClient/src/application-client.xml b/ch2/HelloWorldProject/HelloWorldClient/src/application-client.xml
new file mode 100644
index 0000000..89169e8
--- /dev/null
+++ b/ch2/HelloWorldProject/HelloWorldClient/src/application-client.xml
@@ -0,0 +1,8 @@
+
+
+ helloworldejbclient
+
+ helloworld.client.HelloWorldClient/helloWorld
+ helloworld.ejb.HelloWorld
+
+
diff --git a/ch2/HelloWorldProject/HelloWorldClient/src/helloworld/client/HelloWorldClient.java b/ch2/HelloWorldProject/HelloWorldClient/src/helloworld/client/HelloWorldClient.java
new file mode 100644
index 0000000..c308cbb
--- /dev/null
+++ b/ch2/HelloWorldProject/HelloWorldClient/src/helloworld/client/HelloWorldClient.java
@@ -0,0 +1,12 @@
+package helloworld.client;
+
+import javax.ejb.EJB;
+import helloworld.ejb.HelloWorld;
+public class HelloWorldClient {
+ @EJB
+ private static HelloWorld helloWorld;
+ public static void main (String[] args)
+ {
+ System.out.println(helloWorld.outputHelloWorld());
+ }
+}
\ No newline at end of file
diff --git a/ch2/HelloWorldProject/HelloWorldClient/target/META-INF/MANIFEST.MF b/ch2/HelloWorldProject/HelloWorldClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..c834a8e
--- /dev/null
+++ b/ch2/HelloWorldProject/HelloWorldClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: helloworld.client.HelloWorldClient
+
diff --git a/ch2/HelloWorldProject/HelloWorldClient/target/helloworld/client/HelloWorldClient.class b/ch2/HelloWorldProject/HelloWorldClient/target/helloworld/client/HelloWorldClient.class
new file mode 100644
index 0000000..044cf89
Binary files /dev/null and b/ch2/HelloWorldProject/HelloWorldClient/target/helloworld/client/HelloWorldClient.class differ
diff --git a/ch2/HelloWorldProject/HelloWorldEJB/dist/helloworldejb.jar b/ch2/HelloWorldProject/HelloWorldEJB/dist/helloworldejb.jar
new file mode 100644
index 0000000..07e6877
Binary files /dev/null and b/ch2/HelloWorldProject/HelloWorldEJB/dist/helloworldejb.jar differ
diff --git a/ch2/HelloWorldProject/HelloWorldEJB/src/helloworld/ejb/HelloWorld.java b/ch2/HelloWorldProject/HelloWorldEJB/src/helloworld/ejb/HelloWorld.java
new file mode 100644
index 0000000..6a7b4b7
--- /dev/null
+++ b/ch2/HelloWorldProject/HelloWorldEJB/src/helloworld/ejb/HelloWorld.java
@@ -0,0 +1,6 @@
+package helloworld.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface HelloWorld {
+ public String outputHelloWorld();
+}
diff --git a/ch2/HelloWorldProject/HelloWorldEJB/src/helloworld/ejb/HelloWorldBean.java b/ch2/HelloWorldProject/HelloWorldEJB/src/helloworld/ejb/HelloWorldBean.java
new file mode 100644
index 0000000..b67304f
--- /dev/null
+++ b/ch2/HelloWorldProject/HelloWorldEJB/src/helloworld/ejb/HelloWorldBean.java
@@ -0,0 +1,8 @@
+package helloworld.ejb;
+import javax.ejb.Stateless;
+@Stateless
+public class HelloWorldBean implements helloworld.ejb.HelloWorld {
+ public String outputHelloWorld() {
+ return "Hello World!";
+ }
+}
\ No newline at end of file
diff --git a/ch2/HelloWorldProject/HelloWorldEJB/target/helloworld/ejb/HelloWorld.class b/ch2/HelloWorldProject/HelloWorldEJB/target/helloworld/ejb/HelloWorld.class
new file mode 100644
index 0000000..2c858d5
Binary files /dev/null and b/ch2/HelloWorldProject/HelloWorldEJB/target/helloworld/ejb/HelloWorld.class differ
diff --git a/ch2/HelloWorldProject/HelloWorldEJB/target/helloworld/ejb/HelloWorldBean.class b/ch2/HelloWorldProject/HelloWorldEJB/target/helloworld/ejb/HelloWorldBean.class
new file mode 100644
index 0000000..0d21a33
Binary files /dev/null and b/ch2/HelloWorldProject/HelloWorldEJB/target/helloworld/ejb/HelloWorldBean.class differ
diff --git a/ch2/HelloWorldProject/dist/helloworldapp.jar b/ch2/HelloWorldProject/dist/helloworldapp.jar
new file mode 100644
index 0000000..60149db
Binary files /dev/null and b/ch2/HelloWorldProject/dist/helloworldapp.jar differ
diff --git a/ch2/HelloWorldProject/target/META-INF/application.xml b/ch2/HelloWorldProject/target/META-INF/application.xml
new file mode 100644
index 0000000..dbb6983
--- /dev/null
+++ b/ch2/HelloWorldProject/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ helloworldejb
+
+ helloworldejb.jar
+
+
+ helloworldclient.jar
+
+
diff --git a/ch2/HelloWorldProject/target/helloworldclient.jar b/ch2/HelloWorldProject/target/helloworldclient.jar
new file mode 100644
index 0000000..686c734
Binary files /dev/null and b/ch2/HelloWorldProject/target/helloworldclient.jar differ
diff --git a/ch2/HelloWorldProject/target/helloworldejb.jar b/ch2/HelloWorldProject/target/helloworldejb.jar
new file mode 100644
index 0000000..07e6877
Binary files /dev/null and b/ch2/HelloWorldProject/target/helloworldejb.jar differ
diff --git a/ch4/DeploymentDescriptors/AppClient/dist/appclient-order.jar b/ch4/DeploymentDescriptors/AppClient/dist/appclient-order.jar
new file mode 100644
index 0000000..29e5f63
Binary files /dev/null and b/ch4/DeploymentDescriptors/AppClient/dist/appclient-order.jar differ
diff --git a/ch4/DeploymentDescriptors/AppClient/src/ejbjpa/client/OrderSessionClient.java b/ch4/DeploymentDescriptors/AppClient/src/ejbjpa/client/OrderSessionClient.java
new file mode 100644
index 0000000..ae87b88
--- /dev/null
+++ b/ch4/DeploymentDescriptors/AppClient/src/ejbjpa/client/OrderSessionClient.java
@@ -0,0 +1,15 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.OrderSession;
+public class OrderSessionClient {
+ @EJB
+ private static OrderSession orderSession;
+ public static void main (String[] args)
+ {
+ Integer pono = Integer.parseInt(args[0]);//= 7;
+ Integer cust_id = Integer.parseInt(args[1]); // = 1;
+ Integer units = Integer.parseInt(args[2]); // = 1;
+ String book_id = args[3]; // = "1430209631";
+ orderSession.placeOrder(pono, cust_id, units, book_id);
+ }
+}
\ No newline at end of file
diff --git a/ch4/DeploymentDescriptors/AppClient/target/META-INF/MANIFEST.MF b/ch4/DeploymentDescriptors/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..245bfc1
--- /dev/null
+++ b/ch4/DeploymentDescriptors/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.OrderSessionClient
+
diff --git a/ch4/DeploymentDescriptors/AppClient/target/ejbjpa/client/OrderSessionClient.class b/ch4/DeploymentDescriptors/AppClient/target/ejbjpa/client/OrderSessionClient.class
new file mode 100644
index 0000000..568a70b
Binary files /dev/null and b/ch4/DeploymentDescriptors/AppClient/target/ejbjpa/client/OrderSessionClient.class differ
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/dist/order.jar b/ch4/DeploymentDescriptors/PlaceOrder/dist/order.jar
new file mode 100644
index 0000000..c78047a
Binary files /dev/null and b/ch4/DeploymentDescriptors/PlaceOrder/dist/order.jar differ
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/ejb/OrderSession.java b/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/ejb/OrderSession.java
new file mode 100644
index 0000000..ff2c5c6
--- /dev/null
+++ b/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/ejb/OrderSession.java
@@ -0,0 +1,9 @@
+package ejbjpa.ejb;
+//import javax.ejb.Remote;
+//@Remote
+public interface OrderSession {
+ public void placeOrder(Integer pono,
+ Integer cust_id,
+ Integer units,
+ String book_id);
+}
\ No newline at end of file
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java b/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java
new file mode 100644
index 0000000..a4e79e3
--- /dev/null
+++ b/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java
@@ -0,0 +1,33 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+//import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+//import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+//@Stateless
+public class OrderSessionBean implements OrderSession {
+// @PersistenceUnit(unitName = "order-pu")
+ private EntityManagerFactory emf;
+ public void placeOrder(Integer pono,
+ Integer cust_id,
+ Integer units,
+ String book_id)
+ {
+ try {
+ EntityManager em = emf.createEntityManager();
+ Book book = (Book) em.find(Book.class, book_id);
+ Order order = new Order();
+ order.setPono(pono);
+ order.setCust_id(cust_id);
+ order.setUnits(units);
+ book.setQuantity(book.getQuantity()-units);
+ order.setBook(book);
+ em.persist(order);
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/entities/Book.java b/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/entities/Book.java
new file mode 100644
index 0000000..9dcb6a9
--- /dev/null
+++ b/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/entities/Book.java
@@ -0,0 +1,67 @@
+package ejbjpa.entities;
+import java.util.List;
+import javax.persistence.CascadeType;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.OneToMany;
+@Entity
+@Table(name = "BOOKS")
+public class Book implements Serializable {
+ @Id
+ @Column(name = "ISBN")
+ private String isbn;
+ @Column(name = "TITLE", nullable = false)
+ private String title;
+ @Column(name = "AUTHOR", nullable = false)
+ private String author;
+ @Column(name = "PRICE", nullable = false)
+ private Double price;
+ @Column(name = "QUANTITY", nullable = false)
+ private Integer quantity;
+
+ @OneToMany(mappedBy="book", cascade = CascadeType.ALL)
+ private List orders;
+ public List getOrders(){
+ return orders;
+ }
+ public void setOrders(List orders) {
+ this.orders = orders;
+ }
+
+ public Book() {
+ }
+ public String getIsbn() {
+ return this.isbn;
+ }
+ public void setIsbn(String isbn) {
+ this.isbn = isbn;
+ }
+ public String getTitle() {
+ return this.title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ public String getAuthor() {
+ return this.author;
+ }
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public Double getPrice() {
+ return this.price;
+ }
+ public void setPrice(Double price) {
+ this.price = price;
+ }
+ public Integer getQuantity() {
+ return this.quantity;
+ }
+ public void setQuantity(Integer quantity) {
+ this.quantity = quantity;
+ }
+}
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/entities/Order.java b/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/entities/Order.java
new file mode 100644
index 0000000..9a3eace
--- /dev/null
+++ b/ch4/DeploymentDescriptors/PlaceOrder/src/ejbjpa/entities/Order.java
@@ -0,0 +1,53 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+
+@Entity
+@Table(name = "ORDERS")
+public class Order implements Serializable {
+ @Id
+ @Column(name = "PONO")
+ private Integer pono;
+ @Column(name = "CUST_ID", nullable = false)
+ private Integer cust_id;
+ @Column(name = "UNITS", nullable = false)
+ private Integer units;
+ @ManyToOne
+ @JoinColumn(
+ name="BOOK_ID",
+ referencedColumnName="ISBN")
+ private Book book;
+
+ public Order() {
+ }
+ public Integer getPono() {
+ return this.pono;
+ }
+ public void setPono(Integer pono) {
+ this.pono = pono;
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public Integer getUnits() {
+ return this.units;
+ }
+ public void setUnits(Integer units) {
+ this.units = units;
+ }
+ public Book getBook() {
+ return this.book;
+ }
+ public void setBook(Book book) {
+ this.book = book;
+ }
+
+}
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/target/META-INF/ejb-jar.xml b/ch4/DeploymentDescriptors/PlaceOrder/target/META-INF/ejb-jar.xml
new file mode 100644
index 0000000..7c98a9a
--- /dev/null
+++ b/ch4/DeploymentDescriptors/PlaceOrder/target/META-INF/ejb-jar.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ OrderSessionBean
+ OrderSessionBean
+ ejbjpa.ejb.OrderSession
+ ejbjpa.ejb.OrderSessionBean
+ Stateless
+ Container
+
+ ejbjpa.ejb.OrderSessionBean/emf
+ order-pu
+
+ ejbjpa.ejb.OrderSessionBean
+ emf
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/target/META-INF/persistence.xml b/ch4/DeploymentDescriptors/PlaceOrder/target/META-INF/persistence.xml
new file mode 100644
index 0000000..a9c2a51
--- /dev/null
+++ b/ch4/DeploymentDescriptors/PlaceOrder/target/META-INF/persistence.xml
@@ -0,0 +1,12 @@
+
+
+
+ jdbc/MySQL
+order.jar
+ejbjpa.entities.Order
+ejbjpa.entities.Book
+
+
+
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/ejb/OrderSession.class b/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/ejb/OrderSession.class
new file mode 100644
index 0000000..8227348
Binary files /dev/null and b/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/ejb/OrderSession.class differ
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class b/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class
new file mode 100644
index 0000000..a76f48b
Binary files /dev/null and b/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class differ
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/entities/Book.class b/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/entities/Book.class
new file mode 100644
index 0000000..9ef41e7
Binary files /dev/null and b/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/entities/Book.class differ
diff --git a/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/entities/Order.class b/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/entities/Order.class
new file mode 100644
index 0000000..c7d5b40
Binary files /dev/null and b/ch4/DeploymentDescriptors/PlaceOrder/target/ejbjpa/entities/Order.class differ
diff --git a/ch4/DeploymentDescriptors/dist/deployment-descriptors.jar b/ch4/DeploymentDescriptors/dist/deployment-descriptors.jar
new file mode 100644
index 0000000..5ba299c
Binary files /dev/null and b/ch4/DeploymentDescriptors/dist/deployment-descriptors.jar differ
diff --git a/ch4/DeploymentDescriptors/target/META-INF/application.xml b/ch4/DeploymentDescriptors/target/META-INF/application.xml
new file mode 100644
index 0000000..c86078d
--- /dev/null
+++ b/ch4/DeploymentDescriptors/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ deployment-descriptors
+
+ order.jar
+
+
+ appclient-order.jar
+
+
\ No newline at end of file
diff --git a/ch4/DeploymentDescriptors/target/appclient-order.jar b/ch4/DeploymentDescriptors/target/appclient-order.jar
new file mode 100644
index 0000000..29e5f63
Binary files /dev/null and b/ch4/DeploymentDescriptors/target/appclient-order.jar differ
diff --git a/ch4/DeploymentDescriptors/target/order.jar b/ch4/DeploymentDescriptors/target/order.jar
new file mode 100644
index 0000000..c78047a
Binary files /dev/null and b/ch4/DeploymentDescriptors/target/order.jar differ
diff --git a/ch4/JPAPlanningBidirectional/AppClient/dist/appclient-bidirectional.jar b/ch4/JPAPlanningBidirectional/AppClient/dist/appclient-bidirectional.jar
new file mode 100644
index 0000000..0939e0d
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/AppClient/dist/appclient-bidirectional.jar differ
diff --git a/ch4/JPAPlanningBidirectional/AppClient/src/ejbjpa/client/CustomerSessionClient.java b/ch4/JPAPlanningBidirectional/AppClient/src/ejbjpa/client/CustomerSessionClient.java
new file mode 100644
index 0000000..e0af385
--- /dev/null
+++ b/ch4/JPAPlanningBidirectional/AppClient/src/ejbjpa/client/CustomerSessionClient.java
@@ -0,0 +1,11 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.CustomerSession;
+public class CustomerSessionClient {
+ @EJB
+ private static CustomerSession customerSession;
+ public static void main (String[] args)
+ {
+ System.out.println("Details of the customer whose billing address id=1 is: "+customerSession.getCustomerDetails(1));
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningBidirectional/AppClient/target/META-INF/MANIFEST.MF b/ch4/JPAPlanningBidirectional/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e455a43
--- /dev/null
+++ b/ch4/JPAPlanningBidirectional/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.CustomerSessionClient
+
diff --git a/ch4/JPAPlanningBidirectional/AppClient/target/ejbjpa/client/CustomerSessionClient.class b/ch4/JPAPlanningBidirectional/AppClient/target/ejbjpa/client/CustomerSessionClient.class
new file mode 100644
index 0000000..59048bd
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/AppClient/target/ejbjpa/client/CustomerSessionClient.class differ
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/dist/jpaplanning-bidirectional.jar b/ch4/JPAPlanningBidirectional/JPAPlanning/dist/jpaplanning-bidirectional.jar
new file mode 100644
index 0000000..c776006
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/JPAPlanning/dist/jpaplanning-bidirectional.jar differ
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java b/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
new file mode 100644
index 0000000..e26769e
--- /dev/null
+++ b/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface CustomerSession {
+ public String getCustomerDetails(Integer cust_address_id);
+}
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java b/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
new file mode 100644
index 0000000..d72c65b
--- /dev/null
+++ b/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
@@ -0,0 +1,28 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class CustomerSessionBean implements CustomerSession {
+ @PersistenceUnit(unitName = "ejbjpa-relation-pu")
+ private EntityManagerFactory emf;
+ public String getCustomerDetails(Integer cust_address_id) {
+ String cust_details;
+ try {
+ EntityManager em = emf.createEntityManager();
+ Address addr = em.find(Address.class, cust_address_id);
+ cust_details = addr.getCustomer().getCompany_name()+", "+
+ addr.getCustomer().getPhone()+", "+
+ "address id is "+" "+
+ addr.getCustomer().getAddress().getCust_address_id();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return cust_details;
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/entities/Address.java b/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/entities/Address.java
new file mode 100644
index 0000000..e0b0c1a
--- /dev/null
+++ b/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/entities/Address.java
@@ -0,0 +1,67 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.OneToOne;
+
+@Entity
+@Table(name = "BILLING_ADDRESSES")
+public class Address implements Serializable {
+ @Id
+ @Column(name = "CUST_ADDRESS_ID")
+ private Integer cust_address_id;
+ @Column(name = "STREET", nullable = false)
+ private String street;
+ @Column(name = "CITY", nullable = false)
+ private String city;
+ @Column(name = "STATE", nullable = false)
+ private String state;
+ @Column(name = "ZIPCODE", nullable = false)
+ private String zipcode;
+ @OneToOne(mappedBy="address")
+
+ private Customer customer;
+
+ public Address() {
+ }
+ public Customer getCustomer () {
+ return this.customer;
+ }
+ public void setCustomer(Customer customer) {
+ this.customer= customer;
+ }
+
+ public Integer getCust_address_id() {
+ return this.cust_address_id;
+ }
+ public void setCust_address_id(Integer cust_address_id) {
+ this.cust_address_id = cust_address_id;
+ }
+ public String getStreet() {
+ return this.street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getCity() {
+ return this.city;
+ }
+ public void setCity(String city) {
+ this.city = city;
+ }
+ public String getState() {
+ return this.state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getZipcode() {
+ return this.zipcode;
+ }
+ public void setZipcode(String zipcode) {
+ this.zipcode = zipcode;
+ }
+
+}
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/entities/Customer.java b/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/entities/Customer.java
new file mode 100644
index 0000000..7bf89c1
--- /dev/null
+++ b/ch4/JPAPlanningBidirectional/JPAPlanning/src/ejbjpa/entities/Customer.java
@@ -0,0 +1,50 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.OneToOne;
+import javax.persistence.PrimaryKeyJoinColumn;
+@Entity
+@Table(name = "CUSTOMERS")
+public class Customer implements Serializable {
+ @Id
+ @Column(name = "CUST_ID")
+ private Integer cust_id;
+ @Column(name = "COMPANY_NAME", nullable = false)
+ private String company_name;
+ @Column(name = "PHONE", nullable = false)
+ private String phone;
+ @OneToOne
+ @PrimaryKeyJoinColumn(
+ name="CUST_ID",
+ referencedColumnName="CUST_ADDRESS_ID")
+ private Address address;
+ public Customer() {
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public String getCompany_name() {
+ return this.company_name;
+ }
+ public void setCompany_name(String company_name) {
+ this.company_name = company_name;
+ }
+ public String getPhone() {
+ return this.phone;
+ }
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+ public Address getAddress() {
+ return this.address;
+ }
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+}
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/target/META-INF/persistence.xml b/ch4/JPAPlanningBidirectional/JPAPlanning/target/META-INF/persistence.xml
new file mode 100644
index 0000000..b107ced
--- /dev/null
+++ b/ch4/JPAPlanningBidirectional/JPAPlanning/target/META-INF/persistence.xml
@@ -0,0 +1,12 @@
+
+
+
+ jdbc/MySQL
+jpaplanning-bidirectional.jar
+ejbjpa.entities.Customer
+ejbjpa.entities.Address
+
+
+
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class b/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class
new file mode 100644
index 0000000..1262df7
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class differ
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class b/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class
new file mode 100644
index 0000000..81e3e0f
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class differ
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/entities/Address.class b/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/entities/Address.class
new file mode 100644
index 0000000..dbdeb63
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/entities/Address.class differ
diff --git a/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/entities/Customer.class b/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/entities/Customer.class
new file mode 100644
index 0000000..be30355
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/JPAPlanning/target/ejbjpa/entities/Customer.class differ
diff --git a/ch4/JPAPlanningBidirectional/dist/_bidirectionalapp.jar b/ch4/JPAPlanningBidirectional/dist/_bidirectionalapp.jar
new file mode 100644
index 0000000..e922865
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/dist/_bidirectionalapp.jar differ
diff --git a/ch4/JPAPlanningBidirectional/dist/bidirectional.jar b/ch4/JPAPlanningBidirectional/dist/bidirectional.jar
new file mode 100644
index 0000000..d98afb2
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/dist/bidirectional.jar differ
diff --git a/ch4/JPAPlanningBidirectional/target/META-INF/application.xml b/ch4/JPAPlanningBidirectional/target/META-INF/application.xml
new file mode 100644
index 0000000..19a7fd9
--- /dev/null
+++ b/ch4/JPAPlanningBidirectional/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ ejbjpa-relation
+
+ jpaplanning-bidirectional.jar
+
+
+ appclient-bidirectional.jar
+
+
diff --git a/ch4/JPAPlanningBidirectional/target/appclient-bidirectional.jar b/ch4/JPAPlanningBidirectional/target/appclient-bidirectional.jar
new file mode 100644
index 0000000..0939e0d
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/target/appclient-bidirectional.jar differ
diff --git a/ch4/JPAPlanningBidirectional/target/jpaplanning-bidirectional.jar b/ch4/JPAPlanningBidirectional/target/jpaplanning-bidirectional.jar
new file mode 100644
index 0000000..c776006
Binary files /dev/null and b/ch4/JPAPlanningBidirectional/target/jpaplanning-bidirectional.jar differ
diff --git a/ch4/JPAPlanningTwoTables/AppClient/dist/appclient-view.jar b/ch4/JPAPlanningTwoTables/AppClient/dist/appclient-view.jar
new file mode 100644
index 0000000..16ddc2c
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/AppClient/dist/appclient-view.jar differ
diff --git a/ch4/JPAPlanningTwoTables/AppClient/src/ejbjpa/client/CustomerSessionClient.java b/ch4/JPAPlanningTwoTables/AppClient/src/ejbjpa/client/CustomerSessionClient.java
new file mode 100644
index 0000000..7f9b6a2
--- /dev/null
+++ b/ch4/JPAPlanningTwoTables/AppClient/src/ejbjpa/client/CustomerSessionClient.java
@@ -0,0 +1,11 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.CustomerSession;
+public class CustomerSessionClient {
+ @EJB
+ private static CustomerSession customerSession;
+ public static void main (String[] args)
+ {
+ System.out.println("Details of the customer whose id=1 is: "+customerSession.getCustomerDetails(1));
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningTwoTables/AppClient/target/META-INF/MANIFEST.MF b/ch4/JPAPlanningTwoTables/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e455a43
--- /dev/null
+++ b/ch4/JPAPlanningTwoTables/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.CustomerSessionClient
+
diff --git a/ch4/JPAPlanningTwoTables/AppClient/target/ejbjpa/client/CustomerSessionClient.class b/ch4/JPAPlanningTwoTables/AppClient/target/ejbjpa/client/CustomerSessionClient.class
new file mode 100644
index 0000000..1b12188
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/AppClient/target/ejbjpa/client/CustomerSessionClient.class differ
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/dist/jpaplanning-twotables.jar b/ch4/JPAPlanningTwoTables/JPAPlanning/dist/jpaplanning-twotables.jar
new file mode 100644
index 0000000..e2a6c37
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/JPAPlanning/dist/jpaplanning-twotables.jar differ
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/dist/twotables.jar b/ch4/JPAPlanningTwoTables/JPAPlanning/dist/twotables.jar
new file mode 100644
index 0000000..e6d9ab2
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/JPAPlanning/dist/twotables.jar differ
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java b/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
new file mode 100644
index 0000000..c9c3985
--- /dev/null
+++ b/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface CustomerSession {
+ public String getCustomerDetails(Integer cust_id);
+}
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java b/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
new file mode 100644
index 0000000..f1ee52d
--- /dev/null
+++ b/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
@@ -0,0 +1,31 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class CustomerSessionBean implements CustomerSession {
+ @PersistenceUnit(unitName = "jpaplanning-twotables-pu")
+ private EntityManagerFactory emf;
+ public String getCustomerDetails(Integer cust_id) {
+ String cust_details;
+ try {
+ EntityManager em = emf.createEntityManager();
+ Customer cust = em.find(Customer.class, cust_id);
+ cust_details = cust.getCompany_name()+", "+
+ cust.getPhone()+", "+
+ "address is: "+" "+
+ cust.getStreet()+", "+
+ cust.getCity()+", "+
+ cust.getState()+", "+
+ cust.getZipcode();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return cust_details;
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/entities/Customer.java b/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/entities/Customer.java
new file mode 100644
index 0000000..32aa1fd
--- /dev/null
+++ b/ch4/JPAPlanningTwoTables/JPAPlanning/src/ejbjpa/entities/Customer.java
@@ -0,0 +1,77 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.SecondaryTable;
+import javax.persistence.PrimaryKeyJoinColumn;
+@Entity
+@Table(name = "CUSTOMERS")
+@SecondaryTable(name="BILLING_ADDRESSES",
+ pkJoinColumns=@PrimaryKeyJoinColumn(
+ name="CUST_ADDRESS_ID",
+ referencedColumnName="CUST_ID"))
+public class Customer implements Serializable {
+ @Id
+ @Column(name = "CUST_ID")
+ private Integer cust_id;
+ @Column(name = "COMPANY_NAME", nullable = false)
+ private String company_name;
+ @Column(name = "PHONE", nullable = false)
+ private String phone;
+ @Column(name = "STREET", table="BILLING_ADDRESSES", nullable = false)
+ private String street;
+ @Column(name = "CITY", table="BILLING_ADDRESSES", nullable = false)
+ private String city;
+ @Column(name = "STATE", table="BILLING_ADDRESSES", nullable = false)
+ private String state;
+ @Column(name = "ZIPCODE", table="BILLING_ADDRESSES", nullable = false)
+ private String zipcode;
+ public Customer() {
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public String getCompany_name() {
+ return this.company_name;
+ }
+ public void setCompany_name(String company_name) {
+ this.company_name = company_name;
+ }
+ public String getPhone() {
+ return this.phone;
+ }
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getStreet() {
+ return this.street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getCity() {
+ return this.city;
+ }
+ public void setCity(String city) {
+ this.city = city;
+ }
+ public String getState() {
+ return this.state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getZipcode() {
+ return this.zipcode;
+ }
+ public void setZipcode(String zipcode) {
+ this.zipcode = zipcode;
+ }
+
+}
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/target/META-INF/persistence.xml b/ch4/JPAPlanningTwoTables/JPAPlanning/target/META-INF/persistence.xml
new file mode 100644
index 0000000..7a71a4f
--- /dev/null
+++ b/ch4/JPAPlanningTwoTables/JPAPlanning/target/META-INF/persistence.xml
@@ -0,0 +1,11 @@
+
+
+
+ jdbc/MySQL
+jpaplanning-twotables.jar
+ejbjpa.entities.Customer
+
+
+
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class b/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class
new file mode 100644
index 0000000..1262df7
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class differ
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class b/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class
new file mode 100644
index 0000000..fde87d5
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class differ
diff --git a/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/entities/Customer.class b/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/entities/Customer.class
new file mode 100644
index 0000000..fd7babb
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/JPAPlanning/target/ejbjpa/entities/Customer.class differ
diff --git a/ch4/JPAPlanningTwoTables/dist/twotables.jar b/ch4/JPAPlanningTwoTables/dist/twotables.jar
new file mode 100644
index 0000000..8c2fd35
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/dist/twotables.jar differ
diff --git a/ch4/JPAPlanningTwoTables/dist/view.jar b/ch4/JPAPlanningTwoTables/dist/view.jar
new file mode 100644
index 0000000..8031184
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/dist/view.jar differ
diff --git a/ch4/JPAPlanningTwoTables/target/META-INF/application.xml b/ch4/JPAPlanningTwoTables/target/META-INF/application.xml
new file mode 100644
index 0000000..e144837
--- /dev/null
+++ b/ch4/JPAPlanningTwoTables/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ jpaplanning-view
+
+ jpaplanning-twotables.jar
+
+
+ appclient-view.jar
+
+
diff --git a/ch4/JPAPlanningTwoTables/target/appclient-view.jar b/ch4/JPAPlanningTwoTables/target/appclient-view.jar
new file mode 100644
index 0000000..16ddc2c
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/target/appclient-view.jar differ
diff --git a/ch4/JPAPlanningTwoTables/target/jpaplanning-twotables.jar b/ch4/JPAPlanningTwoTables/target/jpaplanning-twotables.jar
new file mode 100644
index 0000000..e2a6c37
Binary files /dev/null and b/ch4/JPAPlanningTwoTables/target/jpaplanning-twotables.jar differ
diff --git a/ch4/JPAPlanningUnidirectional/AppClient/dist/appclient-unidirectional.jar b/ch4/JPAPlanningUnidirectional/AppClient/dist/appclient-unidirectional.jar
new file mode 100644
index 0000000..2609e2d
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/AppClient/dist/appclient-unidirectional.jar differ
diff --git a/ch4/JPAPlanningUnidirectional/AppClient/src/ejbjpa/client/CustomerSessionClient.java b/ch4/JPAPlanningUnidirectional/AppClient/src/ejbjpa/client/CustomerSessionClient.java
new file mode 100644
index 0000000..215ce31
--- /dev/null
+++ b/ch4/JPAPlanningUnidirectional/AppClient/src/ejbjpa/client/CustomerSessionClient.java
@@ -0,0 +1,11 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.CustomerSession;
+public class CustomerSessionClient {
+ @EJB
+ private static CustomerSession customerSession;
+ public static void main (String[] args)
+ {
+ System.out.println("Billing address of the customer whose id=1 is: "+customerSession.getCustomerAddress(1));
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningUnidirectional/AppClient/target/META-INF/MANIFEST.MF b/ch4/JPAPlanningUnidirectional/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e455a43
--- /dev/null
+++ b/ch4/JPAPlanningUnidirectional/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.CustomerSessionClient
+
diff --git a/ch4/JPAPlanningUnidirectional/AppClient/target/ejbjpa/client/CustomerSessionClient.class b/ch4/JPAPlanningUnidirectional/AppClient/target/ejbjpa/client/CustomerSessionClient.class
new file mode 100644
index 0000000..2abcf90
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/AppClient/target/ejbjpa/client/CustomerSessionClient.class differ
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/dist/jpaplanning-unidirectional.jar b/ch4/JPAPlanningUnidirectional/JPAPlanning/dist/jpaplanning-unidirectional.jar
new file mode 100644
index 0000000..dbc442f
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/JPAPlanning/dist/jpaplanning-unidirectional.jar differ
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java b/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
new file mode 100644
index 0000000..6d999b7
--- /dev/null
+++ b/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface CustomerSession {
+ public String getCustomerAddress(Integer cust_id);
+}
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java b/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
new file mode 100644
index 0000000..fedfc20
--- /dev/null
+++ b/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
@@ -0,0 +1,28 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class CustomerSessionBean implements CustomerSession {
+ @PersistenceUnit(unitName = "ejbjpa-relation-pu")
+ private EntityManagerFactory emf;
+ public String getCustomerAddress(Integer cust_id) {
+ String cust_address;
+ try {
+ EntityManager em = emf.createEntityManager();
+ Customer cust = em.find(Customer.class, cust_id);
+ cust_address = cust.getAddress().getStreet()+", "+
+ cust.getAddress().getCity()+", "+
+ cust.getAddress().getState()+", "+
+ cust.getAddress().getZipcode();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return cust_address;
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/entities/Address.java b/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/entities/Address.java
new file mode 100644
index 0000000..00bfd2c
--- /dev/null
+++ b/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/entities/Address.java
@@ -0,0 +1,55 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+@Entity
+@Table(name = "BILLING_ADDRESSES")
+public class Address implements Serializable {
+ @Id
+ @Column(name = "CUST_ADDRESS_ID")
+ private Integer cust_address_id;
+ @Column(name = "STREET", nullable = false)
+ private String street;
+ @Column(name = "CITY", nullable = false)
+ private String city;
+ @Column(name = "STATE", nullable = false)
+ private String state;
+ @Column(name = "ZIPCODE", nullable = false)
+ private String zipcode;
+
+ public Address() {
+ }
+ public Integer getCust_address_id() {
+ return this.cust_address_id;
+ }
+ public void setCust_address_id(Integer cust_address_id) {
+ this.cust_address_id = cust_address_id;
+ }
+ public String getStreet() {
+ return this.street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getCity() {
+ return this.city;
+ }
+ public void setCity(String city) {
+ this.city = city;
+ }
+ public String getState() {
+ return this.state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getZipcode() {
+ return this.zipcode;
+ }
+ public void setZipcode(String zipcode) {
+ this.zipcode = zipcode;
+ }
+
+}
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/entities/Customer.java b/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/entities/Customer.java
new file mode 100644
index 0000000..7bf89c1
--- /dev/null
+++ b/ch4/JPAPlanningUnidirectional/JPAPlanning/src/ejbjpa/entities/Customer.java
@@ -0,0 +1,50 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.OneToOne;
+import javax.persistence.PrimaryKeyJoinColumn;
+@Entity
+@Table(name = "CUSTOMERS")
+public class Customer implements Serializable {
+ @Id
+ @Column(name = "CUST_ID")
+ private Integer cust_id;
+ @Column(name = "COMPANY_NAME", nullable = false)
+ private String company_name;
+ @Column(name = "PHONE", nullable = false)
+ private String phone;
+ @OneToOne
+ @PrimaryKeyJoinColumn(
+ name="CUST_ID",
+ referencedColumnName="CUST_ADDRESS_ID")
+ private Address address;
+ public Customer() {
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public String getCompany_name() {
+ return this.company_name;
+ }
+ public void setCompany_name(String company_name) {
+ this.company_name = company_name;
+ }
+ public String getPhone() {
+ return this.phone;
+ }
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+ public Address getAddress() {
+ return this.address;
+ }
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+}
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/target/META-INF/persistence.xml b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/META-INF/persistence.xml
new file mode 100644
index 0000000..c226712
--- /dev/null
+++ b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/META-INF/persistence.xml
@@ -0,0 +1,12 @@
+
+
+
+ jdbc/MySQL
+jpaplanning-unidirectional.jar
+ejbjpa.entities.Customer
+ejbjpa.entities.Address
+
+
+
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class
new file mode 100644
index 0000000..3834ec7
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class differ
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class
new file mode 100644
index 0000000..cc07f0b
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class differ
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/entities/Address.class b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/entities/Address.class
new file mode 100644
index 0000000..feb0405
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/entities/Address.class differ
diff --git a/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/entities/Customer.class b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/entities/Customer.class
new file mode 100644
index 0000000..be30355
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/JPAPlanning/target/ejbjpa/entities/Customer.class differ
diff --git a/ch4/JPAPlanningUnidirectional/dist/unidirectionalapp.jar b/ch4/JPAPlanningUnidirectional/dist/unidirectionalapp.jar
new file mode 100644
index 0000000..01d9235
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/dist/unidirectionalapp.jar differ
diff --git a/ch4/JPAPlanningUnidirectional/target/META-INF/application.xml b/ch4/JPAPlanningUnidirectional/target/META-INF/application.xml
new file mode 100644
index 0000000..8793416
--- /dev/null
+++ b/ch4/JPAPlanningUnidirectional/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ ejbjpa-relation
+
+ jpaplanning-unidirectional.jar
+
+
+ appclient-unidirectional.jar
+
+
diff --git a/ch4/JPAPlanningUnidirectional/target/appclient-unidirectional.jar b/ch4/JPAPlanningUnidirectional/target/appclient-unidirectional.jar
new file mode 100644
index 0000000..2609e2d
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/target/appclient-unidirectional.jar differ
diff --git a/ch4/JPAPlanningUnidirectional/target/jpaplanning-unidirectional.jar b/ch4/JPAPlanningUnidirectional/target/jpaplanning-unidirectional.jar
new file mode 100644
index 0000000..dbc442f
Binary files /dev/null and b/ch4/JPAPlanningUnidirectional/target/jpaplanning-unidirectional.jar differ
diff --git a/ch4/JPAPlanningView/AppClient/dist/appclient-view.jar b/ch4/JPAPlanningView/AppClient/dist/appclient-view.jar
new file mode 100644
index 0000000..16ddc2c
Binary files /dev/null and b/ch4/JPAPlanningView/AppClient/dist/appclient-view.jar differ
diff --git a/ch4/JPAPlanningView/AppClient/src/ejbjpa/client/CustomerSessionClient.java b/ch4/JPAPlanningView/AppClient/src/ejbjpa/client/CustomerSessionClient.java
new file mode 100644
index 0000000..7f9b6a2
--- /dev/null
+++ b/ch4/JPAPlanningView/AppClient/src/ejbjpa/client/CustomerSessionClient.java
@@ -0,0 +1,11 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.CustomerSession;
+public class CustomerSessionClient {
+ @EJB
+ private static CustomerSession customerSession;
+ public static void main (String[] args)
+ {
+ System.out.println("Details of the customer whose id=1 is: "+customerSession.getCustomerDetails(1));
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningView/AppClient/target/META-INF/MANIFEST.MF b/ch4/JPAPlanningView/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e455a43
--- /dev/null
+++ b/ch4/JPAPlanningView/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.CustomerSessionClient
+
diff --git a/ch4/JPAPlanningView/AppClient/target/ejbjpa/client/CustomerSessionClient.class b/ch4/JPAPlanningView/AppClient/target/ejbjpa/client/CustomerSessionClient.class
new file mode 100644
index 0000000..1b12188
Binary files /dev/null and b/ch4/JPAPlanningView/AppClient/target/ejbjpa/client/CustomerSessionClient.class differ
diff --git a/ch4/JPAPlanningView/JPAPlanning/dist/jpaplanning-view.jar b/ch4/JPAPlanningView/JPAPlanning/dist/jpaplanning-view.jar
new file mode 100644
index 0000000..84ec048
Binary files /dev/null and b/ch4/JPAPlanningView/JPAPlanning/dist/jpaplanning-view.jar differ
diff --git a/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java b/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
new file mode 100644
index 0000000..c9c3985
--- /dev/null
+++ b/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface CustomerSession {
+ public String getCustomerDetails(Integer cust_id);
+}
diff --git a/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java b/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
new file mode 100644
index 0000000..8508603
--- /dev/null
+++ b/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
@@ -0,0 +1,31 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class CustomerSessionBean implements CustomerSession {
+ @PersistenceUnit(unitName = "jpaplanning-view-pu")
+ private EntityManagerFactory emf;
+ public String getCustomerDetails(Integer cust_id) {
+ String cust_details;
+ try {
+ EntityManager em = emf.createEntityManager();
+ Customer cust = em.find(Customer.class, cust_id);
+ cust_details = cust.getCompany_name()+", "+
+ cust.getPhone()+", "+
+ "address is: "+" "+
+ cust.getStreet()+", "+
+ cust.getCity()+", "+
+ cust.getState()+", "+
+ cust.getZipcode();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return cust_details;
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/entities/Customer.java b/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/entities/Customer.java
new file mode 100644
index 0000000..a6b0ec9
--- /dev/null
+++ b/ch4/JPAPlanningView/JPAPlanning/src/ejbjpa/entities/Customer.java
@@ -0,0 +1,72 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+@Entity
+@Table(name = "CUSTOMERS_V")
+public class Customer implements Serializable {
+ @Id
+ @Column(name = "CUST_ID")
+ private Integer cust_id;
+ @Column(name = "COMPANY_NAME", nullable = false)
+ private String company_name;
+ @Column(name = "PHONE", nullable = false)
+ private String phone;
+ @Column(name = "STREET", nullable = false)
+ private String street;
+ @Column(name = "CITY", nullable = false)
+ private String city;
+ @Column(name = "STATE", nullable = false)
+ private String state;
+ @Column(name = "ZIPCODE", nullable = false)
+ private String zipcode;
+
+ public Customer() {
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public String getCompany_name() {
+ return this.company_name;
+ }
+ public void setCompany_name(String company_name) {
+ this.company_name = company_name;
+ }
+ public String getPhone() {
+ return this.phone;
+ }
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getStreet() {
+ return this.street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getCity() {
+ return this.city;
+ }
+ public void setCity(String city) {
+ this.city = city;
+ }
+ public String getState() {
+ return this.state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getZipcode() {
+ return this.zipcode;
+ }
+ public void setZipcode(String zipcode) {
+ this.zipcode = zipcode;
+ }
+
+}
diff --git a/ch4/JPAPlanningView/JPAPlanning/target/META-INF/persistence.xml b/ch4/JPAPlanningView/JPAPlanning/target/META-INF/persistence.xml
new file mode 100644
index 0000000..8de4ba8
--- /dev/null
+++ b/ch4/JPAPlanningView/JPAPlanning/target/META-INF/persistence.xml
@@ -0,0 +1,11 @@
+
+
+
+ jdbc/MySQL
+jpaplanning-view.jar
+ejbjpa.entities.Customer
+
+
+
diff --git a/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class b/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class
new file mode 100644
index 0000000..1262df7
Binary files /dev/null and b/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class differ
diff --git a/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class b/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class
new file mode 100644
index 0000000..f79c232
Binary files /dev/null and b/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class differ
diff --git a/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/entities/Customer.class b/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/entities/Customer.class
new file mode 100644
index 0000000..da05364
Binary files /dev/null and b/ch4/JPAPlanningView/JPAPlanning/target/ejbjpa/entities/Customer.class differ
diff --git a/ch4/JPAPlanningView/dist/view.jar b/ch4/JPAPlanningView/dist/view.jar
new file mode 100644
index 0000000..8031184
Binary files /dev/null and b/ch4/JPAPlanningView/dist/view.jar differ
diff --git a/ch4/JPAPlanningView/target/META-INF/application.xml b/ch4/JPAPlanningView/target/META-INF/application.xml
new file mode 100644
index 0000000..bc65d8d
--- /dev/null
+++ b/ch4/JPAPlanningView/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ jpaplanning-view
+
+ jpaplanning-view.jar
+
+
+ appclient-view.jar
+
+
diff --git a/ch4/JPAPlanningView/target/appclient-view.jar b/ch4/JPAPlanningView/target/appclient-view.jar
new file mode 100644
index 0000000..16ddc2c
Binary files /dev/null and b/ch4/JPAPlanningView/target/appclient-view.jar differ
diff --git a/ch4/JPAPlanningView/target/jpaplanning-view.jar b/ch4/JPAPlanningView/target/jpaplanning-view.jar
new file mode 100644
index 0000000..84ec048
Binary files /dev/null and b/ch4/JPAPlanningView/target/jpaplanning-view.jar differ
diff --git a/ch4/JPAPlanningViewUpdate/AppClient/dist/appclient-view.jar b/ch4/JPAPlanningViewUpdate/AppClient/dist/appclient-view.jar
new file mode 100644
index 0000000..16ddc2c
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/AppClient/dist/appclient-view.jar differ
diff --git a/ch4/JPAPlanningViewUpdate/AppClient/src/ejbjpa/client/CustomerSessionClient.java b/ch4/JPAPlanningViewUpdate/AppClient/src/ejbjpa/client/CustomerSessionClient.java
new file mode 100644
index 0000000..7f9b6a2
--- /dev/null
+++ b/ch4/JPAPlanningViewUpdate/AppClient/src/ejbjpa/client/CustomerSessionClient.java
@@ -0,0 +1,11 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.CustomerSession;
+public class CustomerSessionClient {
+ @EJB
+ private static CustomerSession customerSession;
+ public static void main (String[] args)
+ {
+ System.out.println("Details of the customer whose id=1 is: "+customerSession.getCustomerDetails(1));
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningViewUpdate/AppClient/target/META-INF/MANIFEST.MF b/ch4/JPAPlanningViewUpdate/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e455a43
--- /dev/null
+++ b/ch4/JPAPlanningViewUpdate/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.CustomerSessionClient
+
diff --git a/ch4/JPAPlanningViewUpdate/AppClient/target/ejbjpa/client/CustomerSessionClient.class b/ch4/JPAPlanningViewUpdate/AppClient/target/ejbjpa/client/CustomerSessionClient.class
new file mode 100644
index 0000000..1b12188
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/AppClient/target/ejbjpa/client/CustomerSessionClient.class differ
diff --git a/ch4/JPAPlanningViewUpdate/JPAPlanning/dist/jpaplanning-view-update.jar b/ch4/JPAPlanningViewUpdate/JPAPlanning/dist/jpaplanning-view-update.jar
new file mode 100644
index 0000000..081febd
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/JPAPlanning/dist/jpaplanning-view-update.jar differ
diff --git a/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java b/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
new file mode 100644
index 0000000..c9c3985
--- /dev/null
+++ b/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/ejb/CustomerSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface CustomerSession {
+ public String getCustomerDetails(Integer cust_id);
+}
diff --git a/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java b/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
new file mode 100644
index 0000000..c6e75b0
--- /dev/null
+++ b/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/ejb/CustomerSessionBean.java
@@ -0,0 +1,35 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class CustomerSessionBean implements CustomerSession {
+ @PersistenceUnit(unitName = "jpaplanning-view-update-pu")
+ private EntityManagerFactory emf;
+ public String getCustomerDetails(Integer cust_id) {
+ String cust_details;
+ try {
+ EntityManager em = emf.createEntityManager();
+ Customer cust = em.find(Customer.class, cust_id);
+ cust.setPhone("(650)777-5669");
+ em.flush();
+ cust.setZipcode("94401");
+ em.flush();
+ cust_details = cust.getCompany_name()+", "+
+ cust.getPhone()+", "+
+ "address is: "+" "+
+ cust.getStreet()+", "+
+ cust.getCity()+", "+
+ cust.getState()+", "+
+ cust.getZipcode();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return cust_details;
+ }
+}
\ No newline at end of file
diff --git a/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/entities/Customer.java b/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/entities/Customer.java
new file mode 100644
index 0000000..a6b0ec9
--- /dev/null
+++ b/ch4/JPAPlanningViewUpdate/JPAPlanning/src/ejbjpa/entities/Customer.java
@@ -0,0 +1,72 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+@Entity
+@Table(name = "CUSTOMERS_V")
+public class Customer implements Serializable {
+ @Id
+ @Column(name = "CUST_ID")
+ private Integer cust_id;
+ @Column(name = "COMPANY_NAME", nullable = false)
+ private String company_name;
+ @Column(name = "PHONE", nullable = false)
+ private String phone;
+ @Column(name = "STREET", nullable = false)
+ private String street;
+ @Column(name = "CITY", nullable = false)
+ private String city;
+ @Column(name = "STATE", nullable = false)
+ private String state;
+ @Column(name = "ZIPCODE", nullable = false)
+ private String zipcode;
+
+ public Customer() {
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public String getCompany_name() {
+ return this.company_name;
+ }
+ public void setCompany_name(String company_name) {
+ this.company_name = company_name;
+ }
+ public String getPhone() {
+ return this.phone;
+ }
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getStreet() {
+ return this.street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getCity() {
+ return this.city;
+ }
+ public void setCity(String city) {
+ this.city = city;
+ }
+ public String getState() {
+ return this.state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getZipcode() {
+ return this.zipcode;
+ }
+ public void setZipcode(String zipcode) {
+ this.zipcode = zipcode;
+ }
+
+}
diff --git a/ch4/JPAPlanningViewUpdate/JPAPlanning/target/META-INF/persistence.xml b/ch4/JPAPlanningViewUpdate/JPAPlanning/target/META-INF/persistence.xml
new file mode 100644
index 0000000..ec567eb
--- /dev/null
+++ b/ch4/JPAPlanningViewUpdate/JPAPlanning/target/META-INF/persistence.xml
@@ -0,0 +1,11 @@
+
+
+
+ jdbc/MySQL
+jpaplanning-view-update.jar
+ejbjpa.entities.Customer
+
+
+
diff --git a/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class b/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class
new file mode 100644
index 0000000..1262df7
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/ejb/CustomerSession.class differ
diff --git a/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class b/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class
new file mode 100644
index 0000000..868a305
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/ejb/CustomerSessionBean.class differ
diff --git a/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/entities/Customer.class b/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/entities/Customer.class
new file mode 100644
index 0000000..da05364
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/JPAPlanning/target/ejbjpa/entities/Customer.class differ
diff --git a/ch4/JPAPlanningViewUpdate/dist/view-update.jar b/ch4/JPAPlanningViewUpdate/dist/view-update.jar
new file mode 100644
index 0000000..4506038
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/dist/view-update.jar differ
diff --git a/ch4/JPAPlanningViewUpdate/dist/view.jar b/ch4/JPAPlanningViewUpdate/dist/view.jar
new file mode 100644
index 0000000..6d71b44
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/dist/view.jar differ
diff --git a/ch4/JPAPlanningViewUpdate/target/META-INF/application.xml b/ch4/JPAPlanningViewUpdate/target/META-INF/application.xml
new file mode 100644
index 0000000..47ad081
--- /dev/null
+++ b/ch4/JPAPlanningViewUpdate/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ jpaplanning-view-update
+
+ jpaplanning-view-update.jar
+
+
+ appclient-view.jar
+
+
diff --git a/ch4/JPAPlanningViewUpdate/target/appclient-view.jar b/ch4/JPAPlanningViewUpdate/target/appclient-view.jar
new file mode 100644
index 0000000..16ddc2c
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/target/appclient-view.jar differ
diff --git a/ch4/JPAPlanningViewUpdate/target/jpaplanning-view-update.jar b/ch4/JPAPlanningViewUpdate/target/jpaplanning-view-update.jar
new file mode 100644
index 0000000..081febd
Binary files /dev/null and b/ch4/JPAPlanningViewUpdate/target/jpaplanning-view-update.jar differ
diff --git a/ch4/TransactionsPlanning/AppClient/dist/appclient-order.jar b/ch4/TransactionsPlanning/AppClient/dist/appclient-order.jar
new file mode 100644
index 0000000..59863eb
Binary files /dev/null and b/ch4/TransactionsPlanning/AppClient/dist/appclient-order.jar differ
diff --git a/ch4/TransactionsPlanning/AppClient/src/ejbjpa/client/OrderSessionClient.java b/ch4/TransactionsPlanning/AppClient/src/ejbjpa/client/OrderSessionClient.java
new file mode 100644
index 0000000..69aff36
--- /dev/null
+++ b/ch4/TransactionsPlanning/AppClient/src/ejbjpa/client/OrderSessionClient.java
@@ -0,0 +1,15 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.OrderSession;
+public class OrderSessionClient {
+ @EJB
+ private static OrderSession orderSession;
+ public static void main (String[] args)
+ {
+ Integer pono = Integer.parseInt(args[0]); //= 7;
+ Integer cust_id = Integer.parseInt(args[1]); // = 1;
+ Integer units = Integer.parseInt(args[2]); // = 1;
+ String book_id = args[3]; // = "1430209631";
+ orderSession.placeOrder(pono, cust_id, units, book_id);
+ }
+}
\ No newline at end of file
diff --git a/ch4/TransactionsPlanning/AppClient/target/META-INF/MANIFEST.MF b/ch4/TransactionsPlanning/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..245bfc1
--- /dev/null
+++ b/ch4/TransactionsPlanning/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.OrderSessionClient
+
diff --git a/ch4/TransactionsPlanning/AppClient/target/ejbjpa/client/OrderSessionClient.class b/ch4/TransactionsPlanning/AppClient/target/ejbjpa/client/OrderSessionClient.class
new file mode 100644
index 0000000..568a70b
Binary files /dev/null and b/ch4/TransactionsPlanning/AppClient/target/ejbjpa/client/OrderSessionClient.class differ
diff --git a/ch4/TransactionsPlanning/PlaceOrder/dist/order.jar b/ch4/TransactionsPlanning/PlaceOrder/dist/order.jar
new file mode 100644
index 0000000..3e12692
Binary files /dev/null and b/ch4/TransactionsPlanning/PlaceOrder/dist/order.jar differ
diff --git a/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/ejb/OrderSession.java b/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/ejb/OrderSession.java
new file mode 100644
index 0000000..8578fe3
--- /dev/null
+++ b/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/ejb/OrderSession.java
@@ -0,0 +1,9 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface OrderSession {
+ public void placeOrder(Integer pono,
+ Integer cust_id,
+ Integer units,
+ String book_id);
+}
diff --git a/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java b/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java
new file mode 100644
index 0000000..23569cf
--- /dev/null
+++ b/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java
@@ -0,0 +1,33 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class OrderSessionBean implements OrderSession {
+ @PersistenceUnit(unitName = "order-pu")
+ private EntityManagerFactory emf;
+ public void placeOrder(Integer pono,
+ Integer cust_id,
+ Integer units,
+ String book_id)
+ {
+ try {
+ EntityManager em = emf.createEntityManager();
+ Book book = (Book) em.find(Book.class, book_id);
+ Order order = new Order();
+ order.setPono(pono);
+ order.setCust_id(cust_id);
+ order.setUnits(units);
+ book.setQuantity(book.getQuantity()-units);
+ order.setBook(book);
+ em.persist(order);
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/entities/Book.java b/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/entities/Book.java
new file mode 100644
index 0000000..ce545d6
--- /dev/null
+++ b/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/entities/Book.java
@@ -0,0 +1,68 @@
+package ejbjpa.entities;
+import java.util.List;
+import javax.persistence.CascadeType;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.OneToMany;
+@Entity
+@Table(name = "BOOKS")
+public class Book implements Serializable {
+
+ @Id
+ @Column(name = "ISBN")
+ private String isbn;
+ @Column(name = "TITLE", nullable = false)
+ private String title;
+ @Column(name = "AUTHOR", nullable = false)
+ private String author;
+ @Column(name = "PRICE", nullable = false)
+ private Double price;
+ @Column(name = "QUANTITY", nullable = false)
+ private Integer quantity;
+
+ @OneToMany(mappedBy="book", cascade = CascadeType.ALL)
+ private List orders;
+ public List getOrders(){
+ return orders;
+ }
+ public void setOrders(List orders) {
+ this.orders = orders;
+ }
+
+ public Book() {
+ }
+ public String getIsbn() {
+ return this.isbn;
+ }
+ public void setIsbn(String isbn) {
+ this.isbn = isbn;
+ }
+ public String getTitle() {
+ return this.title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ public String getAuthor() {
+ return this.author;
+ }
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public Double getPrice() {
+ return this.price;
+ }
+ public void setPrice(Double price) {
+ this.price = price;
+ }
+ public Integer getQuantity() {
+ return this.quantity;
+ }
+ public void setQuantity(Integer quantity) {
+ this.quantity = quantity;
+ }
+}
diff --git a/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/entities/Order.java b/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/entities/Order.java
new file mode 100644
index 0000000..dfd6c01
--- /dev/null
+++ b/ch4/TransactionsPlanning/PlaceOrder/src/ejbjpa/entities/Order.java
@@ -0,0 +1,54 @@
+package ejbjpa.entities;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+
+@Entity
+@Table(name = "ORDERS")
+public class Order implements Serializable {
+ @Id
+ @Column(name = "PONO")
+ private Integer pono;
+ @Column(name = "CUST_ID", nullable = false)
+ private Integer cust_id;
+ @Column(name = "UNITS", nullable = false)
+ private Integer units;
+ @ManyToOne
+ @JoinColumn(
+ name="BOOK_ID",
+ referencedColumnName="ISBN")
+ private Book book;
+
+ public Order() {
+ }
+ public Integer getPono() {
+ return this.pono;
+ }
+ public void setPono(Integer pono) {
+ this.pono = pono;
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public Integer getUnits() {
+ return this.units;
+ }
+ public void setUnits(Integer units) {
+ this.units = units;
+ }
+ public Book getBook() {
+ return this.book;
+ }
+ public void setBook(Book book) {
+ this.book = book;
+ }
+
+}
diff --git a/ch4/TransactionsPlanning/PlaceOrder/target/META-INF/persistence.xml b/ch4/TransactionsPlanning/PlaceOrder/target/META-INF/persistence.xml
new file mode 100644
index 0000000..e4ca601
--- /dev/null
+++ b/ch4/TransactionsPlanning/PlaceOrder/target/META-INF/persistence.xml
@@ -0,0 +1,13 @@
+
+
+
+ jdbc/MySQL
+order.jar
+ejbjpa.entities.Order
+ejbjpa.entities.Book
+
+
+
+
diff --git a/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/ejb/OrderSession.class b/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/ejb/OrderSession.class
new file mode 100644
index 0000000..b19ddac
Binary files /dev/null and b/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/ejb/OrderSession.class differ
diff --git a/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class b/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class
new file mode 100644
index 0000000..c73ae4e
Binary files /dev/null and b/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class differ
diff --git a/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/entities/Book.class b/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/entities/Book.class
new file mode 100644
index 0000000..72fea7e
Binary files /dev/null and b/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/entities/Book.class differ
diff --git a/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/entities/Order.class b/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/entities/Order.class
new file mode 100644
index 0000000..3907d1c
Binary files /dev/null and b/ch4/TransactionsPlanning/PlaceOrder/target/ejbjpa/entities/Order.class differ
diff --git a/ch4/TransactionsPlanning/dist/order.jar b/ch4/TransactionsPlanning/dist/order.jar
new file mode 100644
index 0000000..dcb298a
Binary files /dev/null and b/ch4/TransactionsPlanning/dist/order.jar differ
diff --git a/ch4/TransactionsPlanning/dist/transactions-planning.jar b/ch4/TransactionsPlanning/dist/transactions-planning.jar
new file mode 100644
index 0000000..e879385
Binary files /dev/null and b/ch4/TransactionsPlanning/dist/transactions-planning.jar differ
diff --git a/ch4/TransactionsPlanning/dist/view-update.jar b/ch4/TransactionsPlanning/dist/view-update.jar
new file mode 100644
index 0000000..4506038
Binary files /dev/null and b/ch4/TransactionsPlanning/dist/view-update.jar differ
diff --git a/ch4/TransactionsPlanning/dist/view.jar b/ch4/TransactionsPlanning/dist/view.jar
new file mode 100644
index 0000000..6d71b44
Binary files /dev/null and b/ch4/TransactionsPlanning/dist/view.jar differ
diff --git a/ch4/TransactionsPlanning/target/META-INF/application.xml b/ch4/TransactionsPlanning/target/META-INF/application.xml
new file mode 100644
index 0000000..c3280d3
--- /dev/null
+++ b/ch4/TransactionsPlanning/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ transactions-planning
+
+ order.jar
+
+
+ appclient-order.jar
+
+
diff --git a/ch4/TransactionsPlanning/target/appclient-order.jar b/ch4/TransactionsPlanning/target/appclient-order.jar
new file mode 100644
index 0000000..59863eb
Binary files /dev/null and b/ch4/TransactionsPlanning/target/appclient-order.jar differ
diff --git a/ch4/TransactionsPlanning/target/order.jar b/ch4/TransactionsPlanning/target/order.jar
new file mode 100644
index 0000000..3e12692
Binary files /dev/null and b/ch4/TransactionsPlanning/target/order.jar differ
diff --git a/ch4/TwoEjbs/AppClient/dist/appclient-client.jar b/ch4/TwoEjbs/AppClient/dist/appclient-client.jar
new file mode 100644
index 0000000..8e32379
Binary files /dev/null and b/ch4/TwoEjbs/AppClient/dist/appclient-client.jar differ
diff --git a/ch4/TwoEjbs/AppClient/src/ejbjpa/client/OrderSessionClient.java b/ch4/TwoEjbs/AppClient/src/ejbjpa/client/OrderSessionClient.java
new file mode 100644
index 0000000..5f5de79
--- /dev/null
+++ b/ch4/TwoEjbs/AppClient/src/ejbjpa/client/OrderSessionClient.java
@@ -0,0 +1,19 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.OrderSession;
+import ejbjpa.ejb.CustSession;
+public class OrderSessionClient {
+ @EJB
+ private static CustSession custSession;
+ @EJB
+ private static OrderSession orderSession;
+ public static void main (String[] args)
+ {
+ Integer pono = Integer.parseInt(args[0]);//= 7;
+ String company_name = args[1]; // = 1;
+ Integer units = Integer.parseInt(args[2]); // = 1;
+ String book_id = args[3]; // = "1430209631";
+ Integer cust_id = custSession.getCustId(company_name);
+ orderSession.placeOrder(pono, cust_id, units, book_id);
+ }
+}
\ No newline at end of file
diff --git a/ch4/TwoEjbs/AppClient/target/META-INF/MANIFEST.MF b/ch4/TwoEjbs/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..245bfc1
--- /dev/null
+++ b/ch4/TwoEjbs/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.OrderSessionClient
+
diff --git a/ch4/TwoEjbs/AppClient/target/ejbjpa/client/OrderSessionClient.class b/ch4/TwoEjbs/AppClient/target/ejbjpa/client/OrderSessionClient.class
new file mode 100644
index 0000000..4128302
Binary files /dev/null and b/ch4/TwoEjbs/AppClient/target/ejbjpa/client/OrderSessionClient.class differ
diff --git a/ch4/TwoEjbs/GetCust/dist/cust.jar b/ch4/TwoEjbs/GetCust/dist/cust.jar
new file mode 100644
index 0000000..29866aa
Binary files /dev/null and b/ch4/TwoEjbs/GetCust/dist/cust.jar differ
diff --git a/ch4/TwoEjbs/GetCust/src/ejbjpa/ejb/CustSession.java b/ch4/TwoEjbs/GetCust/src/ejbjpa/ejb/CustSession.java
new file mode 100644
index 0000000..dfe651e
--- /dev/null
+++ b/ch4/TwoEjbs/GetCust/src/ejbjpa/ejb/CustSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface CustSession {
+ public Integer getCustId(String company_name);
+}
\ No newline at end of file
diff --git a/ch4/TwoEjbs/GetCust/src/ejbjpa/ejb/CustSessionBean.java b/ch4/TwoEjbs/GetCust/src/ejbjpa/ejb/CustSessionBean.java
new file mode 100644
index 0000000..6ea5501
--- /dev/null
+++ b/ch4/TwoEjbs/GetCust/src/ejbjpa/ejb/CustSessionBean.java
@@ -0,0 +1,28 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class CustSessionBean implements CustSession {
+ @PersistenceUnit(unitName = "cust-pu")
+ private EntityManagerFactory emf;
+ public Integer getCustId(String company_name)
+ {
+ Integer cust_id;
+ try {
+ EntityManager em = emf.createEntityManager();
+ Customer customer = (Customer) em.createQuery("SELECT c FROM Customer c WHERE c.company_name LIKE :company_name")
+ .setParameter("company_name", company_name)
+.getSingleResult();
+ cust_id = customer.getCust_id();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return cust_id;
+ }
+}
\ No newline at end of file
diff --git a/ch4/TwoEjbs/GetCust/src/ejbjpa/entities/Customer.java b/ch4/TwoEjbs/GetCust/src/ejbjpa/entities/Customer.java
new file mode 100644
index 0000000..af6f9ec
--- /dev/null
+++ b/ch4/TwoEjbs/GetCust/src/ejbjpa/entities/Customer.java
@@ -0,0 +1,36 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+@Entity
+@Table(name = "CUSTOMERS")
+public class Customer implements Serializable {
+ @Id
+ @Column(name = "CUST_ID")
+ private Integer cust_id;
+ @Column(name = "COMPANY_NAME", nullable = false)
+ private String company_name;
+ @Column(name = "PHONE", nullable = false)
+ private String phone;
+
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public String getCompany_name() {
+ return this.company_name;
+ }
+ public void setCompany_name(String company_name) {
+ this.company_name = company_name;
+ }
+ public String getPhone() {
+ return this.phone;
+ }
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+}
diff --git a/ch4/TwoEjbs/GetCust/target/META-INF/persistence.xml b/ch4/TwoEjbs/GetCust/target/META-INF/persistence.xml
new file mode 100644
index 0000000..d292c24
--- /dev/null
+++ b/ch4/TwoEjbs/GetCust/target/META-INF/persistence.xml
@@ -0,0 +1,11 @@
+
+
+
+ jdbc/MySQL
+cust.jar
+ejbjpa.entities.Customer
+
+
+
diff --git a/ch4/TwoEjbs/GetCust/target/ejbjpa/ejb/CustSession.class b/ch4/TwoEjbs/GetCust/target/ejbjpa/ejb/CustSession.class
new file mode 100644
index 0000000..e5886ec
Binary files /dev/null and b/ch4/TwoEjbs/GetCust/target/ejbjpa/ejb/CustSession.class differ
diff --git a/ch4/TwoEjbs/GetCust/target/ejbjpa/ejb/CustSessionBean.class b/ch4/TwoEjbs/GetCust/target/ejbjpa/ejb/CustSessionBean.class
new file mode 100644
index 0000000..acc4151
Binary files /dev/null and b/ch4/TwoEjbs/GetCust/target/ejbjpa/ejb/CustSessionBean.class differ
diff --git a/ch4/TwoEjbs/GetCust/target/ejbjpa/entities/Customer.class b/ch4/TwoEjbs/GetCust/target/ejbjpa/entities/Customer.class
new file mode 100644
index 0000000..0ff0b83
Binary files /dev/null and b/ch4/TwoEjbs/GetCust/target/ejbjpa/entities/Customer.class differ
diff --git a/ch4/TwoEjbs/PlaceOrder/dist/order.jar b/ch4/TwoEjbs/PlaceOrder/dist/order.jar
new file mode 100644
index 0000000..c0d8a5c
Binary files /dev/null and b/ch4/TwoEjbs/PlaceOrder/dist/order.jar differ
diff --git a/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/ejb/OrderSession.java b/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/ejb/OrderSession.java
new file mode 100644
index 0000000..ff2c5c6
--- /dev/null
+++ b/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/ejb/OrderSession.java
@@ -0,0 +1,9 @@
+package ejbjpa.ejb;
+//import javax.ejb.Remote;
+//@Remote
+public interface OrderSession {
+ public void placeOrder(Integer pono,
+ Integer cust_id,
+ Integer units,
+ String book_id);
+}
\ No newline at end of file
diff --git a/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java b/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java
new file mode 100644
index 0000000..a4e79e3
--- /dev/null
+++ b/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java
@@ -0,0 +1,33 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+//import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+//import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+//@Stateless
+public class OrderSessionBean implements OrderSession {
+// @PersistenceUnit(unitName = "order-pu")
+ private EntityManagerFactory emf;
+ public void placeOrder(Integer pono,
+ Integer cust_id,
+ Integer units,
+ String book_id)
+ {
+ try {
+ EntityManager em = emf.createEntityManager();
+ Book book = (Book) em.find(Book.class, book_id);
+ Order order = new Order();
+ order.setPono(pono);
+ order.setCust_id(cust_id);
+ order.setUnits(units);
+ book.setQuantity(book.getQuantity()-units);
+ order.setBook(book);
+ em.persist(order);
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/entities/Book.java b/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/entities/Book.java
new file mode 100644
index 0000000..9dcb6a9
--- /dev/null
+++ b/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/entities/Book.java
@@ -0,0 +1,67 @@
+package ejbjpa.entities;
+import java.util.List;
+import javax.persistence.CascadeType;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.OneToMany;
+@Entity
+@Table(name = "BOOKS")
+public class Book implements Serializable {
+ @Id
+ @Column(name = "ISBN")
+ private String isbn;
+ @Column(name = "TITLE", nullable = false)
+ private String title;
+ @Column(name = "AUTHOR", nullable = false)
+ private String author;
+ @Column(name = "PRICE", nullable = false)
+ private Double price;
+ @Column(name = "QUANTITY", nullable = false)
+ private Integer quantity;
+
+ @OneToMany(mappedBy="book", cascade = CascadeType.ALL)
+ private List orders;
+ public List getOrders(){
+ return orders;
+ }
+ public void setOrders(List orders) {
+ this.orders = orders;
+ }
+
+ public Book() {
+ }
+ public String getIsbn() {
+ return this.isbn;
+ }
+ public void setIsbn(String isbn) {
+ this.isbn = isbn;
+ }
+ public String getTitle() {
+ return this.title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ public String getAuthor() {
+ return this.author;
+ }
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public Double getPrice() {
+ return this.price;
+ }
+ public void setPrice(Double price) {
+ this.price = price;
+ }
+ public Integer getQuantity() {
+ return this.quantity;
+ }
+ public void setQuantity(Integer quantity) {
+ this.quantity = quantity;
+ }
+}
diff --git a/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/entities/Order.java b/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/entities/Order.java
new file mode 100644
index 0000000..9a3eace
--- /dev/null
+++ b/ch4/TwoEjbs/PlaceOrder/src/ejbjpa/entities/Order.java
@@ -0,0 +1,53 @@
+package ejbjpa.entities;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+
+@Entity
+@Table(name = "ORDERS")
+public class Order implements Serializable {
+ @Id
+ @Column(name = "PONO")
+ private Integer pono;
+ @Column(name = "CUST_ID", nullable = false)
+ private Integer cust_id;
+ @Column(name = "UNITS", nullable = false)
+ private Integer units;
+ @ManyToOne
+ @JoinColumn(
+ name="BOOK_ID",
+ referencedColumnName="ISBN")
+ private Book book;
+
+ public Order() {
+ }
+ public Integer getPono() {
+ return this.pono;
+ }
+ public void setPono(Integer pono) {
+ this.pono = pono;
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public Integer getUnits() {
+ return this.units;
+ }
+ public void setUnits(Integer units) {
+ this.units = units;
+ }
+ public Book getBook() {
+ return this.book;
+ }
+ public void setBook(Book book) {
+ this.book = book;
+ }
+
+}
diff --git a/ch4/TwoEjbs/PlaceOrder/target/META-INF/ejb-jar.xml b/ch4/TwoEjbs/PlaceOrder/target/META-INF/ejb-jar.xml
new file mode 100644
index 0000000..7c98a9a
--- /dev/null
+++ b/ch4/TwoEjbs/PlaceOrder/target/META-INF/ejb-jar.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ OrderSessionBean
+ OrderSessionBean
+ ejbjpa.ejb.OrderSession
+ ejbjpa.ejb.OrderSessionBean
+ Stateless
+ Container
+
+ ejbjpa.ejb.OrderSessionBean/emf
+ order-pu
+
+ ejbjpa.ejb.OrderSessionBean
+ emf
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ch4/TwoEjbs/PlaceOrder/target/META-INF/persistence.xml b/ch4/TwoEjbs/PlaceOrder/target/META-INF/persistence.xml
new file mode 100644
index 0000000..a9c2a51
--- /dev/null
+++ b/ch4/TwoEjbs/PlaceOrder/target/META-INF/persistence.xml
@@ -0,0 +1,12 @@
+
+
+
+ jdbc/MySQL
+order.jar
+ejbjpa.entities.Order
+ejbjpa.entities.Book
+
+
+
diff --git a/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/ejb/OrderSession.class b/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/ejb/OrderSession.class
new file mode 100644
index 0000000..8227348
Binary files /dev/null and b/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/ejb/OrderSession.class differ
diff --git a/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class b/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class
new file mode 100644
index 0000000..a76f48b
Binary files /dev/null and b/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class differ
diff --git a/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/entities/Book.class b/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/entities/Book.class
new file mode 100644
index 0000000..9ef41e7
Binary files /dev/null and b/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/entities/Book.class differ
diff --git a/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/entities/Order.class b/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/entities/Order.class
new file mode 100644
index 0000000..c7d5b40
Binary files /dev/null and b/ch4/TwoEjbs/PlaceOrder/target/ejbjpa/entities/Order.class differ
diff --git a/ch4/TwoEjbs/dist/deployment-descriptors.jar b/ch4/TwoEjbs/dist/deployment-descriptors.jar
new file mode 100644
index 0000000..5ba299c
Binary files /dev/null and b/ch4/TwoEjbs/dist/deployment-descriptors.jar differ
diff --git a/ch4/TwoEjbs/dist/deployment-descs.jar b/ch4/TwoEjbs/dist/deployment-descs.jar
new file mode 100644
index 0000000..ed1135f
Binary files /dev/null and b/ch4/TwoEjbs/dist/deployment-descs.jar differ
diff --git a/ch4/TwoEjbs/dist/two-ejbs.jar b/ch4/TwoEjbs/dist/two-ejbs.jar
new file mode 100644
index 0000000..9d10abd
Binary files /dev/null and b/ch4/TwoEjbs/dist/two-ejbs.jar differ
diff --git a/ch4/TwoEjbs/target/META-INF/application.xml b/ch4/TwoEjbs/target/META-INF/application.xml
new file mode 100644
index 0000000..2fe9a88
--- /dev/null
+++ b/ch4/TwoEjbs/target/META-INF/application.xml
@@ -0,0 +1,13 @@
+
+
+ two-ejbs
+
+ order.jar
+
+
+ cust.jar
+
+
+ appclient-client.jar
+
+
\ No newline at end of file
diff --git a/ch4/TwoEjbs/target/appclient-client.jar b/ch4/TwoEjbs/target/appclient-client.jar
new file mode 100644
index 0000000..8e32379
Binary files /dev/null and b/ch4/TwoEjbs/target/appclient-client.jar differ
diff --git a/ch4/TwoEjbs/target/cust.jar b/ch4/TwoEjbs/target/cust.jar
new file mode 100644
index 0000000..29866aa
Binary files /dev/null and b/ch4/TwoEjbs/target/cust.jar differ
diff --git a/ch4/TwoEjbs/target/order.jar b/ch4/TwoEjbs/target/order.jar
new file mode 100644
index 0000000..c0d8a5c
Binary files /dev/null and b/ch4/TwoEjbs/target/order.jar differ
diff --git a/ch5/GettingQuantity/AppClient/dist/appclient-book.jar b/ch5/GettingQuantity/AppClient/dist/appclient-book.jar
new file mode 100644
index 0000000..f50a835
Binary files /dev/null and b/ch5/GettingQuantity/AppClient/dist/appclient-book.jar differ
diff --git a/ch5/GettingQuantity/AppClient/src/ejbjpa/client/BookSessionClient.java b/ch5/GettingQuantity/AppClient/src/ejbjpa/client/BookSessionClient.java
new file mode 100644
index 0000000..f88e5b8
--- /dev/null
+++ b/ch5/GettingQuantity/AppClient/src/ejbjpa/client/BookSessionClient.java
@@ -0,0 +1,12 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.BookSession;
+public class BookSessionClient {
+ @EJB
+ private static BookSession bookSession;
+ public static void main (String[] args)
+ {
+ String book_id = args[0]; // = "1430209631";
+ System.out.println(bookSession.gettingQuantity(book_id));
+ }
+}
\ No newline at end of file
diff --git a/ch5/GettingQuantity/AppClient/target/META-INF/MANIFEST.MF b/ch5/GettingQuantity/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..ea84eb4
--- /dev/null
+++ b/ch5/GettingQuantity/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.BookSessionClient
+
diff --git a/ch5/GettingQuantity/AppClient/target/ejbjpa/client/BookSessionClient.class b/ch5/GettingQuantity/AppClient/target/ejbjpa/client/BookSessionClient.class
new file mode 100644
index 0000000..a5510ae
Binary files /dev/null and b/ch5/GettingQuantity/AppClient/target/ejbjpa/client/BookSessionClient.class differ
diff --git a/ch5/GettingQuantity/GetQuantity/dist/book.jar b/ch5/GettingQuantity/GetQuantity/dist/book.jar
new file mode 100644
index 0000000..4b66855
Binary files /dev/null and b/ch5/GettingQuantity/GetQuantity/dist/book.jar differ
diff --git a/ch5/GettingQuantity/GetQuantity/src/ejbjpa/ejb/BookSession.java b/ch5/GettingQuantity/GetQuantity/src/ejbjpa/ejb/BookSession.java
new file mode 100644
index 0000000..64e6b51
--- /dev/null
+++ b/ch5/GettingQuantity/GetQuantity/src/ejbjpa/ejb/BookSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface BookSession {
+ public Integer gettingQuantity(String book_id);
+}
diff --git a/ch5/GettingQuantity/GetQuantity/src/ejbjpa/ejb/BookSessionBean.java b/ch5/GettingQuantity/GetQuantity/src/ejbjpa/ejb/BookSessionBean.java
new file mode 100644
index 0000000..fa8e7fd
--- /dev/null
+++ b/ch5/GettingQuantity/GetQuantity/src/ejbjpa/ejb/BookSessionBean.java
@@ -0,0 +1,31 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.sql.*;
+
+@Stateless
+public class BookSessionBean implements BookSession {
+ @Resource(name="jdbc/MySQL")
+ private DataSource dataSource;
+ public Integer gettingQuantity(String book_id)
+ {
+ Integer qnty;
+ try {
+ Connection conn = dataSource.getConnection();
+ PreparedStatement stmt = conn.prepareStatement("SELECT quantity FROM books WHERE isbn= ?");
+ stmt.setString(1, book_id);
+ ResultSet rslt = stmt.executeQuery();
+ rslt.next();
+ qnty = rslt.getInt("quantity");
+ rslt.close();
+ stmt.close();
+ conn.close();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return qnty;
+ }
+}
\ No newline at end of file
diff --git a/ch5/GettingQuantity/GetQuantity/target/ejbjpa/ejb/BookSession.class b/ch5/GettingQuantity/GetQuantity/target/ejbjpa/ejb/BookSession.class
new file mode 100644
index 0000000..70dc6f3
Binary files /dev/null and b/ch5/GettingQuantity/GetQuantity/target/ejbjpa/ejb/BookSession.class differ
diff --git a/ch5/GettingQuantity/GetQuantity/target/ejbjpa/ejb/BookSessionBean.class b/ch5/GettingQuantity/GetQuantity/target/ejbjpa/ejb/BookSessionBean.class
new file mode 100644
index 0000000..6126c74
Binary files /dev/null and b/ch5/GettingQuantity/GetQuantity/target/ejbjpa/ejb/BookSessionBean.class differ
diff --git a/ch5/GettingQuantity/dist/getting-quantity.jar b/ch5/GettingQuantity/dist/getting-quantity.jar
new file mode 100644
index 0000000..d1ae5f3
Binary files /dev/null and b/ch5/GettingQuantity/dist/getting-quantity.jar differ
diff --git a/ch5/GettingQuantity/target/META-INF/application.xml b/ch5/GettingQuantity/target/META-INF/application.xml
new file mode 100644
index 0000000..6818457
--- /dev/null
+++ b/ch5/GettingQuantity/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ getting-quantity
+
+ book.jar
+
+
+ appclient-book.jar
+
+
diff --git a/ch5/GettingQuantity/target/appclient-book.jar b/ch5/GettingQuantity/target/appclient-book.jar
new file mode 100644
index 0000000..f50a835
Binary files /dev/null and b/ch5/GettingQuantity/target/appclient-book.jar differ
diff --git a/ch5/GettingQuantity/target/book.jar b/ch5/GettingQuantity/target/book.jar
new file mode 100644
index 0000000..4b66855
Binary files /dev/null and b/ch5/GettingQuantity/target/book.jar differ
diff --git a/ch5/ProcessingToData/AppClient/dist/appclient-order.jar b/ch5/ProcessingToData/AppClient/dist/appclient-order.jar
new file mode 100644
index 0000000..59863eb
Binary files /dev/null and b/ch5/ProcessingToData/AppClient/dist/appclient-order.jar differ
diff --git a/ch5/ProcessingToData/AppClient/src/ejbjpa/client/OrderSessionClient.java b/ch5/ProcessingToData/AppClient/src/ejbjpa/client/OrderSessionClient.java
new file mode 100644
index 0000000..69aff36
--- /dev/null
+++ b/ch5/ProcessingToData/AppClient/src/ejbjpa/client/OrderSessionClient.java
@@ -0,0 +1,15 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.OrderSession;
+public class OrderSessionClient {
+ @EJB
+ private static OrderSession orderSession;
+ public static void main (String[] args)
+ {
+ Integer pono = Integer.parseInt(args[0]); //= 7;
+ Integer cust_id = Integer.parseInt(args[1]); // = 1;
+ Integer units = Integer.parseInt(args[2]); // = 1;
+ String book_id = args[3]; // = "1430209631";
+ orderSession.placeOrder(pono, cust_id, units, book_id);
+ }
+}
\ No newline at end of file
diff --git a/ch5/ProcessingToData/AppClient/target/META-INF/MANIFEST.MF b/ch5/ProcessingToData/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..245bfc1
--- /dev/null
+++ b/ch5/ProcessingToData/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.OrderSessionClient
+
diff --git a/ch5/ProcessingToData/AppClient/target/ejbjpa/client/OrderSessionClient.class b/ch5/ProcessingToData/AppClient/target/ejbjpa/client/OrderSessionClient.class
new file mode 100644
index 0000000..568a70b
Binary files /dev/null and b/ch5/ProcessingToData/AppClient/target/ejbjpa/client/OrderSessionClient.class differ
diff --git a/ch5/ProcessingToData/PlaceOrder/dist/order.jar b/ch5/ProcessingToData/PlaceOrder/dist/order.jar
new file mode 100644
index 0000000..6915a4c
Binary files /dev/null and b/ch5/ProcessingToData/PlaceOrder/dist/order.jar differ
diff --git a/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/ejb/OrderSession.java b/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/ejb/OrderSession.java
new file mode 100644
index 0000000..8578fe3
--- /dev/null
+++ b/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/ejb/OrderSession.java
@@ -0,0 +1,9 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface OrderSession {
+ public void placeOrder(Integer pono,
+ Integer cust_id,
+ Integer units,
+ String book_id);
+}
diff --git a/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java b/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java
new file mode 100644
index 0000000..0450718
--- /dev/null
+++ b/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/ejb/OrderSessionBean.java
@@ -0,0 +1,34 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import ejbjpa.entities.*;
+
+@Stateless
+public class OrderSessionBean implements OrderSession {
+ @PersistenceUnit(unitName = "order-pu")
+ private EntityManagerFactory emf;
+ public void placeOrder(Integer pono,
+ Integer cust_id,
+ Integer units,
+ String book_id)
+ {
+ try {
+ EntityManager em = emf.createEntityManager();
+ // Book book = (Book) em.find(Book.class, book_id);
+ Order order = new Order();
+ order.setPono(pono);
+ order.setCust_id(cust_id);
+ order.setBook_id(book_id);
+ order.setUnits(units);
+ // book.setQuantity(book.getQuantity()-units);
+ //order.setBook(book);
+ em.persist(order);
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/entities/Order.java b/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/entities/Order.java
new file mode 100644
index 0000000..f18c7a4
--- /dev/null
+++ b/ch5/ProcessingToData/PlaceOrder/src/ejbjpa/entities/Order.java
@@ -0,0 +1,50 @@
+package ejbjpa.entities;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+
+@Entity
+@Table(name = "ORDERS")
+public class Order implements Serializable {
+ @Id
+ @Column(name = "PONO")
+ private Integer pono;
+ @Column(name = "CUST_ID", nullable = false)
+ private Integer cust_id;
+ @Column(name = "BOOK_ID", nullable = false)
+ private String book_id;
+ @Column(name = "UNITS", nullable = false)
+ private Integer units;
+ public Order() {
+ }
+ public Integer getPono() {
+ return this.pono;
+ }
+ public void setPono(Integer pono) {
+ this.pono = pono;
+ }
+ public Integer getCust_id() {
+ return this.cust_id;
+ }
+ public void setCust_id(Integer cust_id) {
+ this.cust_id = cust_id;
+ }
+ public String getBook_id() {
+ return this.book_id;
+ }
+ public void setBook_id(String book_id) {
+ this.book_id = book_id;
+ }
+ public Integer getUnits() {
+ return this.units;
+ }
+ public void setUnits(Integer units) {
+ this.units = units;
+ }
+
+}
diff --git a/ch5/ProcessingToData/PlaceOrder/target/META-INF/persistence.xml b/ch5/ProcessingToData/PlaceOrder/target/META-INF/persistence.xml
new file mode 100644
index 0000000..12080c9
--- /dev/null
+++ b/ch5/ProcessingToData/PlaceOrder/target/META-INF/persistence.xml
@@ -0,0 +1,12 @@
+
+
+
+ jdbc/MySQL
+order.jar
+ejbjpa.entities.Order
+
+
+
+
diff --git a/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/ejb/OrderSession.class b/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/ejb/OrderSession.class
new file mode 100644
index 0000000..b19ddac
Binary files /dev/null and b/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/ejb/OrderSession.class differ
diff --git a/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class b/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class
new file mode 100644
index 0000000..e8af08d
Binary files /dev/null and b/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/ejb/OrderSessionBean.class differ
diff --git a/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/entities/Order.class b/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/entities/Order.class
new file mode 100644
index 0000000..bffce88
Binary files /dev/null and b/ch5/ProcessingToData/PlaceOrder/target/ejbjpa/entities/Order.class differ
diff --git a/ch5/ProcessingToData/dist/processing-todata.jar b/ch5/ProcessingToData/dist/processing-todata.jar
new file mode 100644
index 0000000..23f5e99
Binary files /dev/null and b/ch5/ProcessingToData/dist/processing-todata.jar differ
diff --git a/ch5/ProcessingToData/target/META-INF/application.xml b/ch5/ProcessingToData/target/META-INF/application.xml
new file mode 100644
index 0000000..c3280d3
--- /dev/null
+++ b/ch5/ProcessingToData/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ transactions-planning
+
+ order.jar
+
+
+ appclient-order.jar
+
+
diff --git a/ch5/ProcessingToData/target/appclient-order.jar b/ch5/ProcessingToData/target/appclient-order.jar
new file mode 100644
index 0000000..59863eb
Binary files /dev/null and b/ch5/ProcessingToData/target/appclient-order.jar differ
diff --git a/ch5/ProcessingToData/target/order.jar b/ch5/ProcessingToData/target/order.jar
new file mode 100644
index 0000000..6915a4c
Binary files /dev/null and b/ch5/ProcessingToData/target/order.jar differ
diff --git a/ch5/QuantityViaFunction/AppClient/dist/appclient-book.jar b/ch5/QuantityViaFunction/AppClient/dist/appclient-book.jar
new file mode 100644
index 0000000..f50a835
Binary files /dev/null and b/ch5/QuantityViaFunction/AppClient/dist/appclient-book.jar differ
diff --git a/ch5/QuantityViaFunction/AppClient/src/ejbjpa/client/BookSessionClient.java b/ch5/QuantityViaFunction/AppClient/src/ejbjpa/client/BookSessionClient.java
new file mode 100644
index 0000000..f88e5b8
--- /dev/null
+++ b/ch5/QuantityViaFunction/AppClient/src/ejbjpa/client/BookSessionClient.java
@@ -0,0 +1,12 @@
+package ejbjpa.client;
+import javax.ejb.EJB;
+import ejbjpa.ejb.BookSession;
+public class BookSessionClient {
+ @EJB
+ private static BookSession bookSession;
+ public static void main (String[] args)
+ {
+ String book_id = args[0]; // = "1430209631";
+ System.out.println(bookSession.gettingQuantity(book_id));
+ }
+}
\ No newline at end of file
diff --git a/ch5/QuantityViaFunction/AppClient/target/META-INF/MANIFEST.MF b/ch5/QuantityViaFunction/AppClient/target/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..ea84eb4
--- /dev/null
+++ b/ch5/QuantityViaFunction/AppClient/target/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ejbjpa.client.BookSessionClient
+
diff --git a/ch5/QuantityViaFunction/AppClient/target/ejbjpa/client/BookSessionClient.class b/ch5/QuantityViaFunction/AppClient/target/ejbjpa/client/BookSessionClient.class
new file mode 100644
index 0000000..a5510ae
Binary files /dev/null and b/ch5/QuantityViaFunction/AppClient/target/ejbjpa/client/BookSessionClient.class differ
diff --git a/ch5/QuantityViaFunction/GetQuantity/dist/book.jar b/ch5/QuantityViaFunction/GetQuantity/dist/book.jar
new file mode 100644
index 0000000..a71cee1
Binary files /dev/null and b/ch5/QuantityViaFunction/GetQuantity/dist/book.jar differ
diff --git a/ch5/QuantityViaFunction/GetQuantity/src/ejbjpa/ejb/BookSession.java b/ch5/QuantityViaFunction/GetQuantity/src/ejbjpa/ejb/BookSession.java
new file mode 100644
index 0000000..64e6b51
--- /dev/null
+++ b/ch5/QuantityViaFunction/GetQuantity/src/ejbjpa/ejb/BookSession.java
@@ -0,0 +1,6 @@
+package ejbjpa.ejb;
+import javax.ejb.Remote;
+@Remote
+public interface BookSession {
+ public Integer gettingQuantity(String book_id);
+}
diff --git a/ch5/QuantityViaFunction/GetQuantity/src/ejbjpa/ejb/BookSessionBean.java b/ch5/QuantityViaFunction/GetQuantity/src/ejbjpa/ejb/BookSessionBean.java
new file mode 100644
index 0000000..904281e
--- /dev/null
+++ b/ch5/QuantityViaFunction/GetQuantity/src/ejbjpa/ejb/BookSessionBean.java
@@ -0,0 +1,31 @@
+package ejbjpa.ejb;
+import java.io.Serializable;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.sql.*;
+
+@Stateless
+public class BookSessionBean implements BookSession {
+ @Resource(name="jdbc/MySQL")
+ private DataSource dataSource;
+ public Integer gettingQuantity(String book_id)
+ {
+ Integer qnty;
+ try {
+ Connection conn = dataSource.getConnection();
+ PreparedStatement stmt = conn.prepareStatement("SELECT copiesInStock(?) as quantity FROM DUAL");
+ stmt.setString(1, book_id);
+ ResultSet rslt = stmt.executeQuery();
+ rslt.next();
+ qnty = rslt.getInt("quantity");
+ rslt.close();
+ stmt.close();
+ conn.close();
+ } catch (Exception e) {
+ throw new EJBException(e.getMessage());
+ }
+ return qnty;
+ }
+}
\ No newline at end of file
diff --git a/ch5/QuantityViaFunction/GetQuantity/target/ejbjpa/ejb/BookSession.class b/ch5/QuantityViaFunction/GetQuantity/target/ejbjpa/ejb/BookSession.class
new file mode 100644
index 0000000..70dc6f3
Binary files /dev/null and b/ch5/QuantityViaFunction/GetQuantity/target/ejbjpa/ejb/BookSession.class differ
diff --git a/ch5/QuantityViaFunction/GetQuantity/target/ejbjpa/ejb/BookSessionBean.class b/ch5/QuantityViaFunction/GetQuantity/target/ejbjpa/ejb/BookSessionBean.class
new file mode 100644
index 0000000..64ee40e
Binary files /dev/null and b/ch5/QuantityViaFunction/GetQuantity/target/ejbjpa/ejb/BookSessionBean.class differ
diff --git a/ch5/QuantityViaFunction/dist/quantity-function.jar b/ch5/QuantityViaFunction/dist/quantity-function.jar
new file mode 100644
index 0000000..a8d0cf0
Binary files /dev/null and b/ch5/QuantityViaFunction/dist/quantity-function.jar differ
diff --git a/ch5/QuantityViaFunction/target/META-INF/application.xml b/ch5/QuantityViaFunction/target/META-INF/application.xml
new file mode 100644
index 0000000..6818457
--- /dev/null
+++ b/ch5/QuantityViaFunction/target/META-INF/application.xml
@@ -0,0 +1,10 @@
+
+
+ getting-quantity
+
+ book.jar
+
+
+ appclient-book.jar
+
+
diff --git a/ch5/QuantityViaFunction/target/appclient-book.jar b/ch5/QuantityViaFunction/target/appclient-book.jar
new file mode 100644
index 0000000..f50a835
Binary files /dev/null and b/ch5/QuantityViaFunction/target/appclient-book.jar differ
diff --git a/ch5/QuantityViaFunction/target/book.jar b/ch5/QuantityViaFunction/target/book.jar
new file mode 100644
index 0000000..a71cee1
Binary files /dev/null and b/ch5/QuantityViaFunction/target/book.jar differ
diff --git a/ch6/deliveryestimatemysql.sql b/ch6/deliveryestimatemysql.sql
new file mode 100644
index 0000000..e536c88
--- /dev/null
+++ b/ch6/deliveryestimatemysql.sql
@@ -0,0 +1,23 @@
+USE dbsample;
+
+delimiter //
+CREATE FUNCTION deliveryEstimate(location_id INT) RETURNS VARCHAR(20)
+BEGIN
+ DECLARE estimate VARCHAR(20);
+ DECLARE location VARCHAR(100);
+ SELECT area INTO location FROM locations WHERE loc_id = location_id;
+ CASE
+ WHEN location = 'US' THEN
+ SET estimate = '2 business days';
+ WHEN location = 'Canada' THEN
+ SET estimate = '2-4 business days';
+WHEN location = 'Europe' THEN
+ SET estimate = '4-6 business days';
+ELSE
+ SET estimate = '8-12 business days';
+ END CASE;
+ RETURN estimate;
+END;
+//
+delimiter ;
+
diff --git a/ch6/deliveryestimateoracle.sql b/ch6/deliveryestimateoracle.sql
new file mode 100644
index 0000000..61b7290
--- /dev/null
+++ b/ch6/deliveryestimateoracle.sql
@@ -0,0 +1,19 @@
+CREATE OR REPLACE FUNCTION deliveryEstimate(location_id NUMBER) RETURN VARCHAR2 AS
+ estimate VARCHAR2(20);
+ location VARCHAR2(100);
+BEGIN
+ SELECT area INTO location FROM locations WHERE loc_id = location_id;
+ estimate :=
+ CASE
+ WHEN location = 'US' THEN
+ '2 business days'
+ WHEN location = 'Canada' THEN
+ '2-4 business days'
+ WHEN location = 'Europe' THEN
+ '4-6 business days'
+ ELSE
+ '8-12 business days'
+ END;
+ RETURN estimate;
+END;
+/
diff --git a/ch6/shippingdatemysql.sql b/ch6/shippingdatemysql.sql
new file mode 100644
index 0000000..500ca28
--- /dev/null
+++ b/ch6/shippingdatemysql.sql
@@ -0,0 +1,19 @@
+USE dbsample;
+
+delimiter //
+CREATE FUNCTION shippingDate() RETURNS DATE
+BEGIN
+ DECLARE dayno INT;
+ DECLARE shpdate DATE;
+ SELECT WEEKDAY(NOW()) INTO dayno;
+ IF dayno < 5 THEN
+ SELECT CURDATE() INTO shpdate;
+ ELSEIF dayno = 5 THEN
+ SELECT DATE_ADD(CURDATE(), INTERVAL 2 DAY) INTO shpdate;
+ ELSEIF dayno = 6 THEN
+ SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY) INTO shpdate;
+ END IF;
+ RETURN shpdate;
+END;
+//
+delimiter ;
diff --git a/ch6/shippingdateoracle.sql b/ch6/shippingdateoracle.sql
new file mode 100644
index 0000000..a083fdb
--- /dev/null
+++ b/ch6/shippingdateoracle.sql
@@ -0,0 +1,13 @@
+CREATE OR REPLACE FUNCTION shippingDate RETURN DATE IS
+ dayno NUMBER;
+ shpdate DATE;
+ BEGIN
+ SELECT TO_NUMBER(TO_CHAR(SYSDATE, 'D')) INTO dayno FROM DUAL;
+ IF (dayno>1) AND (dayno<7) THEN
+ SELECT SYSDATE INTO shpdate FROM DUAL;
+ ELSE
+ SELECT NEXT_DAY(SYSDATE, 'MONDAY') INTO shpdate FROM DUAL;
+ END IF;
+ RETURN shpdate;
+END;
+/
\ No newline at end of file
diff --git a/ch6/tablesmysql.sql b/ch6/tablesmysql.sql
new file mode 100644
index 0000000..8af1a9e
--- /dev/null
+++ b/ch6/tablesmysql.sql
@@ -0,0 +1,72 @@
+USE dbsample;
+
+DROP TABLE IF EXISTS details;
+DROP TABLE IF EXISTS shoppingCarts;
+DROP TABLE IF EXISTS orders;
+DROP TABLE IF EXISTS customers;
+DROP TABLE IF EXISTS locations;
+DROP TABLE IF EXISTS employees;
+DROP TABLE IF EXISTS books;
+
+CREATE TABLE locations (
+ loc_id INTEGER PRIMARY KEY,
+ area VARCHAR(100)
+)
+ENGINE = InnoDB;
+
+CREATE TABLE customers (
+ cust_id INTEGER PRIMARY KEY,
+ cust_name VARCHAR(100),
+ loc_id INTEGER,
+ email VARCHAR(100),
+ phone VARCHAR(20),
+ FOREIGN KEY(loc_id) REFERENCES locations(loc_id)
+)
+ENGINE = InnoDB;
+
+CREATE TABLE employees(
+ empno INTEGER PRIMARY KEY,
+ firstname VARCHAR(30),
+ lastname VARCHAR(30)
+)
+ENGINE = InnoDB;
+
+CREATE TABLE books(
+ isbn VARCHAR(20) PRIMARY KEY,
+ title VARCHAR(150),
+ author VARCHAR(150),
+ quantity INTEGER,
+ price NUMERIC(8,2)
+)
+ENGINE = InnoDB;
+
+CREATE TABLE orders(
+ pono INTEGER PRIMARY KEY,
+ cust_id INTEGER,
+ empno INTEGER,
+ shipping_date DATE,
+ delivery_estimate VARCHAR(20),
+ FOREIGN KEY(cust_id) REFERENCES customers(cust_id),
+ FOREIGN KEY(empno) REFERENCES employees(empno)
+)
+ENGINE = InnoDB;
+
+CREATE TABLE details(
+ ordno INTEGER,
+ book_id VARCHAR(20),
+ units INTEGER,
+ unit_price NUMERIC(8,2),
+ PRIMARY KEY(ordno, book_id),
+ FOREIGN KEY(ordno) REFERENCES orders(pono),
+ FOREIGN KEY(book_id) REFERENCES books(isbn)
+) ENGINE = InnoDB;
+
+CREATE TABLE shoppingCarts(
+ cart_id INTEGER,
+ book_id VARCHAR(20),
+ units INTEGER,
+ unit_price NUMERIC(8,2),
+ PRIMARY KEY(cart_id, book_id),
+ FOREIGN KEY(book_id) REFERENCES books(isbn)
+) ENGINE = InnoDB;
+
diff --git a/ch6/tablesoracle.sql b/ch6/tablesoracle.sql
new file mode 100644
index 0000000..adfad5f
--- /dev/null
+++ b/ch6/tablesoracle.sql
@@ -0,0 +1,64 @@
+DROP TABLE details;
+DROP TABLE shoppingCarts;
+DROP TABLE orders;
+DROP TABLE customers;
+DROP TABLE locations;
+DROP TABLE employees;
+DROP TABLE books;
+
+CREATE TABLE locations (
+ loc_id NUMBER PRIMARY KEY,
+ area VARCHAR2(100)
+);
+
+CREATE TABLE customers (
+ cust_id NUMBER PRIMARY KEY,
+ cust_name VARCHAR2(100),
+ loc_id NUMBER,
+ email VARCHAR2(100),
+ phone VARCHAR2(20),
+ FOREIGN KEY(loc_id) REFERENCES locations(loc_id)
+);
+
+CREATE TABLE employees(
+ empno NUMBER PRIMARY KEY,
+ firstname VARCHAR2(30),
+ lastname VARCHAR2(30)
+);
+
+CREATE TABLE books(
+ isbn VARCHAR2(20) PRIMARY KEY,
+ title VARCHAR2(150),
+ author VARCHAR2(150),
+ quantity NUMBER,
+ price NUMBER(8,2)
+);
+
+CREATE TABLE orders(
+ pono NUMBER PRIMARY KEY,
+ cust_id NUMBER,
+ empno NUMBER,
+ shipping_date DATE,
+ delivery_estimate VARCHAR2(20),
+ FOREIGN KEY(cust_id) REFERENCES customers(cust_id),
+ FOREIGN KEY(empno) REFERENCES employees(empno)
+);
+
+CREATE TABLE details(
+ ordno NUMBER,
+ book_id VARCHAR2(20),
+ units NUMBER,
+ unit_price NUMBER(8,2),
+ PRIMARY KEY(ordno, book_id),
+ FOREIGN KEY(ordno) REFERENCES orders(pono),
+ FOREIGN KEY(book_id) REFERENCES books(isbn)
+);
+
+CREATE TABLE shoppingCarts(
+ cart_id NUMBER,
+ book_id VARCHAR2(20),
+ units NUMBER,
+ unit_price NUMBER(8,2),
+ PRIMARY KEY(cart_id, book_id),
+ FOREIGN KEY(book_id) REFERENCES books(isbn)
+);
diff --git a/ch6/tablespopulatingmysql.sql b/ch6/tablespopulatingmysql.sql
new file mode 100644
index 0000000..8a2026f
--- /dev/null
+++ b/ch6/tablespopulatingmysql.sql
@@ -0,0 +1,19 @@
+USE dbsample;
+
+START TRANSACTION;
+
+INSERT INTO locations VALUES(1, 'US');
+INSERT INTO locations VALUES(2, 'Canada');
+INSERT INTO locations VALUES(3, 'Europe');
+INSERT INTO locations VALUES(4, 'Other');
+
+INSERT INTO customers VALUES(1, 'John Poplavski', 1, 'joshp@mail.com', '(650)777-5665');
+INSERT INTO customers VALUES(2, 'Paul Medica', 3, 'paulmed@mail.com', '(029)2124-5540');
+
+INSERT INTO employees VALUES(1, 'Serg', 'Oganovich');
+INSERT INTO employees VALUES(2, 'Maya', 'Silver');
+
+INSERT INTO books VALUES('1430209631', 'Beginning GlassFish TopLink: From Novice to Professional', 'Yuli Vasiliev', 10, 44.99);
+INSERT INTO books VALUES('1590595300', 'Expert Oracle Databas Architecture: 9i and 10g Programming Techniques and Solutions', 'Thomas Kyte', 10, 49.99);
+
+COMMIT;
diff --git a/ch6/tablespopulatingoracle.sql b/ch6/tablespopulatingoracle.sql
new file mode 100644
index 0000000..d9bc063
--- /dev/null
+++ b/ch6/tablespopulatingoracle.sql
@@ -0,0 +1,15 @@
+INSERT INTO locations VALUES(1, 'US');
+INSERT INTO locations VALUES(2, 'Canada');
+INSERT INTO locations VALUES(3, 'Europe');
+INSERT INTO locations VALUES(4, 'Other');
+
+INSERT INTO customers VALUES(1, 'John Poplavski', 1, 'joshp@mail.com', '(650)777-5665');
+INSERT INTO customers VALUES(2, 'Paul Medica', 3, 'paulmed@mail.com', '(029)2124-5540');
+
+INSERT INTO employees VALUES(1, 'Serg', 'Oganovich');
+INSERT INTO employees VALUES(2, 'Maya', 'Silver');
+
+INSERT INTO books VALUES('1430209631', 'Beginning GlassFish TopLink: From Novice to Professional', 'Yuli Vasiliev', 10, 44.99);
+INSERT INTO books VALUES('1590595300', 'Expert Oracle Databas Architecture: 9i and 10g Programming Techniques and Solutions', 'Thomas Kyte', 10, 49.99);
+
+COMMIT;
diff --git a/ch7/TestDataSource/WEB-INF/sun-web.xml b/ch7/TestDataSource/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..0b3eb44
--- /dev/null
+++ b/ch7/TestDataSource/WEB-INF/sun-web.xml
@@ -0,0 +1,5 @@
+
+
+
+ /testPage
+
\ No newline at end of file
diff --git a/ch7/TestDataSource/WEB-INF/web.xml b/ch7/TestDataSource/WEB-INF/web.xml
new file mode 100644
index 0000000..fc8ffba
--- /dev/null
+++ b/ch7/TestDataSource/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ testPage.jsp
+
+
+
+ jdbc/mysqlpool
+ javax.sql.DataSource
+ Container
+
+
\ No newline at end of file
diff --git a/ch7/TestDataSource/testPage.jsp b/ch7/TestDataSource/testPage.jsp
new file mode 100644
index 0000000..037865e
--- /dev/null
+++ b/ch7/TestDataSource/testPage.jsp
@@ -0,0 +1,23 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+
+
+ select isbn, title, quantity, price from dbsample.books
+
+
+
+ JDBC Connection Test
+
+
+