[jboss-cvs] JBossAS SVN: r82505 - in projects/ejb3/trunk/docs/tutorial: composite and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 23 05:46:15 EST 2008


Author: jaikiran
Date: 2008-12-23 05:46:15 -0500 (Tue, 23 Dec 2008)
New Revision: 82505

Added:
   projects/ejb3/trunk/docs/tutorial/composite/
   projects/ejb3/trunk/docs/tutorial/composite/META-INF/
   projects/ejb3/trunk/docs/tutorial/composite/build.xml
   projects/ejb3/trunk/docs/tutorial/composite/composite.html
   projects/ejb3/trunk/docs/tutorial/composite/composite.wiki
   projects/ejb3/trunk/docs/tutorial/composite/jndi.properties
   projects/ejb3/trunk/docs/tutorial/composite/log4j.xml
   projects/ejb3/trunk/docs/tutorial/composite/src/
Removed:
   projects/ejb3/trunk/docs/tutorial/composite/META-INF/
   projects/ejb3/trunk/docs/tutorial/composite/build.xml
   projects/ejb3/trunk/docs/tutorial/composite/composite.html
   projects/ejb3/trunk/docs/tutorial/composite/composite.wiki
   projects/ejb3/trunk/docs/tutorial/composite/jndi.properties
   projects/ejb3/trunk/docs/tutorial/composite/log4j.xml
   projects/ejb3/trunk/docs/tutorial/composite/src/
Modified:
   projects/ejb3/trunk/docs/tutorial/composite/META-INF/persistence.xml
Log:
Initial working version of the Entities with Composite Keys tutorial, for JBoss-5 GA

Copied: projects/ejb3/trunk/docs/tutorial/composite (from rev 82032, projects/oldstuff/ejb3/docs/tutorial/composite)

Copied: projects/ejb3/trunk/docs/tutorial/composite/META-INF (from rev 82494, projects/oldstuff/ejb3/docs/tutorial/composite/META-INF)

Modified: projects/ejb3/trunk/docs/tutorial/composite/META-INF/persistence.xml
===================================================================
--- projects/oldstuff/ejb3/docs/tutorial/composite/META-INF/persistence.xml	2008-12-23 07:30:02 UTC (rev 82494)
+++ projects/ejb3/trunk/docs/tutorial/composite/META-INF/persistence.xml	2008-12-23 10:46:15 UTC (rev 82505)
@@ -1,5 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<persistence>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+   version="1.0">
    <persistence-unit name="tempdb">
       <jta-data-source>java:/DefaultDS</jta-data-source>
       <properties>

Deleted: projects/ejb3/trunk/docs/tutorial/composite/build.xml
===================================================================
--- projects/oldstuff/ejb3/docs/tutorial/composite/build.xml	2008-12-04 08:31:45 UTC (rev 82032)
+++ projects/ejb3/trunk/docs/tutorial/composite/build.xml	2008-12-23 10:46:15 UTC (rev 82505)
@@ -1,90 +0,0 @@
-<?xml version="1.0"?>
-
-<!-- ======================================================================= -->
-<!-- JBoss build file                                                       -->
-<!-- ======================================================================= -->
-
-<project name="JBoss" default="ejbjar" basedir=".">
-
-   <property environment="env"/>
-   <property name="src.dir" value="${basedir}/src"/>
-   <property name="jboss.home" value="${env.JBOSS_HOME}"/>   <property name="jboss.server.config" value="all"/>
-   <property name="build.dir" value="${basedir}/build"/>
-   <property name="build.classes.dir" value="${build.dir}/classes"/>
-
-   <!-- Build classpath -->
-   <path id="classpath">
-      <!-- So that we can get jndi.properties for InitialContext -->
-      <pathelement location="${basedir}"/>
-      <fileset dir="${jboss.home}/lib">
-         <include name="**/*.jar"/>
-      </fileset>
-      <fileset dir="${jboss.home}/server/${jboss.server.config}/lib">
-         <include name="**/*.jar"/>
-      </fileset>
-      <fileset dir="${jboss.home}/server/${jboss.server.config}/deploy/ejb3.deployer">
-         <include name="*.jar"/>
-      </fileset>
-      <fileset dir="${jboss.home}/server/${jboss.server.config}/deploy/jboss-aop-jdk50.deployer">
-         <include name="*.jar"/>
-      </fileset>
-      <pathelement location="${build.classes.dir}"/>
-   </path>
-
-   <property name="build.classpath" refid="classpath"/>
-
-   <!-- =================================================================== -->
-   <!-- Prepares the build directory                                        -->
-   <!-- =================================================================== -->
-   <target name="prepare">
-      <mkdir dir="${build.dir}"/>
-      <mkdir dir="${build.classes.dir}"/>
-   </target>
-
-   <!-- =================================================================== -->
-   <!-- Compiles the source code                                            -->
-   <!-- =================================================================== -->
-   <target name="compile" depends="prepare">
-      <javac srcdir="${src.dir}"
-         destdir="${build.classes.dir}"
-         debug="on"
-         deprecation="on"
-         optimize="off"
-         includes="**">
-         <classpath refid="classpath"/>
-      </javac>
-   </target>
-
-   <target name="ejbjar" depends="compile">
-      <jar jarfile="build/tutorial.jar">
-         <fileset dir="${build.classes.dir}">
-            <include name="**/*.class"/>
-         </fileset>
-         <fileset dir=".">
-            <include name="META-INF/persistence.xml"/>
-         </fileset>
-      </jar>
-      <copy file="build/tutorial.jar" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
-   </target>
-
-   <target name="run" depends="ejbjar">
-      <java classname="org.jboss.tutorial.composite.client.Client" fork="yes" dir=".">
-         <classpath refid="classpath"/>
-      </java>
-   </target>
-
-   <!-- =================================================================== -->
-   <!-- Cleans up generated stuff                                           -->
-   <!-- =================================================================== -->
-   <target name="clean.db">
-      <delete dir="${jboss.home}/server/${jboss.server.config}/data/hypersonic"/>
-   </target>
-
-   <target name="clean">
-      <delete dir="${build.dir}"/>
-      <delete file="${jboss.home}/server/${jboss.server.config}/deploy/tutorial.jar"/>
-   </target>
-
-
-</project>
-

Copied: projects/ejb3/trunk/docs/tutorial/composite/build.xml (from rev 82494, projects/oldstuff/ejb3/docs/tutorial/composite/build.xml)
===================================================================
--- projects/ejb3/trunk/docs/tutorial/composite/build.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/composite/build.xml	2008-12-23 10:46:15 UTC (rev 82505)
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+
+<!-- ======================================================================= -->
+<!-- JBoss build file                                                       -->
+<!-- ======================================================================= -->
+
+<project name="JBoss" default="ejbjar" basedir=".">
+
+   <property environment="env"/>
+   <property name="src.dir" value="${basedir}/src"/>
+   <property name="jboss.home" value="${env.JBOSS_HOME}"/>
+   <property name="jboss.server.config" value="default"/>
+   <property name="build.dir" value="${basedir}/build"/>
+   <property name="build.classes.dir" value="${build.dir}/classes"/>
+   <property name="build.artifact" value="jboss-ejb3-tutorial-entity-compositekeys.jar"/>
+
+   <!-- Build classpath -->
+   <path id="classpath">
+      <!-- So that we can get jndi.properties for InitialContext -->
+      <pathelement location="${basedir}"/>
+   		<!-- Only the jbossall-client.jar should ideally be sufficient -->
+      <fileset dir="${jboss.home}/client">
+         <include name="**/jbossall-client.jar"/>
+      </fileset>
+      <pathelement location="${build.classes.dir}"/>
+   </path>
+
+   <property name="build.classpath" refid="classpath"/>
+
+   <!-- =================================================================== -->
+   <!-- Prepares the build directory                                        -->
+   <!-- =================================================================== -->
+   <target name="prepare">
+      <mkdir dir="${build.dir}"/>
+      <mkdir dir="${build.classes.dir}"/>
+   </target>
+
+   <!-- =================================================================== -->
+   <!-- Compiles the source code                                            -->
+   <!-- =================================================================== -->
+   <target name="compile" depends="prepare">
+      <javac srcdir="${src.dir}"
+         destdir="${build.classes.dir}"
+         debug="on"
+         deprecation="on"
+         optimize="off"
+         includes="**">
+         <classpath refid="classpath"/>
+      </javac>
+   </target>
+
+   <target name="ejbjar" depends="compile">
+      <jar jarfile="build/${build.artifact}">
+         <fileset dir="${build.classes.dir}">
+            <include name="**/*.class"/>
+         </fileset>
+         <fileset dir=".">
+            <include name="META-INF/persistence.xml"/>
+         </fileset>
+      </jar>
+      <copy file="build/${build.artifact}" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
+   </target>
+
+   <target name="run" depends="ejbjar">
+      <java classname="org.jboss.tutorial.composite.client.Client" fork="yes" dir=".">
+         <classpath refid="classpath"/>
+      </java>
+   </target>
+
+   <!-- =================================================================== -->
+   <!-- Cleans up generated stuff                                           -->
+   <!-- =================================================================== -->
+   <target name="clean.db">
+      <delete dir="${jboss.home}/server/${jboss.server.config}/data/hypersonic"/>
+   </target>
+
+   <target name="clean">
+      <delete dir="${build.dir}"/>
+      <delete file="${jboss.home}/server/${jboss.server.config}/deploy/${build.artifact}"/>
+   </target>
+
+
+</project>
+

Deleted: projects/ejb3/trunk/docs/tutorial/composite/composite.html
===================================================================
--- projects/oldstuff/ejb3/docs/tutorial/composite/composite.html	2008-12-04 08:31:45 UTC (rev 82032)
+++ projects/ejb3/trunk/docs/tutorial/composite/composite.html	2008-12-23 10:46:15 UTC (rev 82505)
@@ -1,157 +0,0 @@
-<html>
-<body>
-<p>
-<h2>Composite Primary Keys and Primary Key Classes</h2>
-
-The EJB 3.0 specification allows you to define a primary key class as a @Embeddable and use it as the primary key of your Entity bean.  One or
-more properties can be used as members of the primary key for that particular table.  This tutorial is an adaptation of the
-<i>relationships</i> tutorial.  It adds a primary key class to Customer that holds both the <i>name</i> and <i>id</i> of the Customer.
-</p><p>
-<pre>
- at Embeddable
-public class CustomerPK implements java.io.Serializable
-{
-   private long id;
-   private String name;
-
-
-   public CustomerPK()
-   {
-   }
-
-   public CustomerPK(long id, String name)
-   {
-      this.id = id;
-      this.name = name;
-   }
-
-   public long getId()
-   {
-      return id;
-   }
-
-   public void setId(long id)
-   {
-      this.id = id;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public int hashCode()
-   {
-      return (int) id + name.hashCode();
-   }
-
-   public boolean equals(Object obj)
-   {
-      if (obj == this) return true;
-      if (!(obj instanceof CustomerPK)) return false;
-      if (obj == null) return false;
-      CustomerPK pk = (CustomerPK) obj;
-      return pk.id == id &amp;&amp; pk.name.equals(name);
-   }
-}
-</pre>
-</p><p>
-<h4>Mapping the primary key class</h4>
-
-Open up <a href="src/org/jboss/tutorial/composite/bean/Customer.java">Customer</a> and look for the <tt>getPk()</tt> method.  This
-defines the primary key class.
-</p><p>
-<pre>
-   @EmbeddedId
-   public CustomerPK getPk()
-   {
-      return pk;
-   }
-</pre>
-</p><p>
-The <a href="src/org/jboss/tutorial/composite/bean/CustomerPK.java">CustomerPK</a> class is mapped to <a href="src/org/jboss/tutorial/composite/bean/Customer.java">Customer</a>
-just like any other embeddable object.  The additional <tt>@EmbeddedId</tt> annotation specifies that it will be the primary key.
-NOTE: If you provide a primary key class, JBoss cannot autogenerate the key
-for you.  You must allocate a CustomerPK class and instantiate it with your id and name when you create the Customer.
-</p><p>
-</p><p>
-<h4>Many To Many</h4>
-
-There is a mant to many relationship between <a href="src/org/jboss/tutorial/composite/bean/Customer.java">Customer</a> and <a href="src/org/jboss/tutorial/composite/bean/Flight.java">Flight</a>.
-  In order to have a many to many relationship there needs to be a distinct join table that maps the many to many relationship.  This is called an association table.
-  You need to use the <tt>@JoinTable</tt> annotation to define this join table.
-  The <tt>@JoinTable</tt> must be defined on both sides of the bi-directional relationship.  Let's look at the Customer side of the relationship
-</p><p>
-<pre>
-   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers")
-   @JoinTable(name="flight_customer_table",
-              joinColumns={@JoinColumn(name = "FLIGHT_ID")},
-              inverseJoinColumns={@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
-   public Set&lt;Flight&gt; getFlights()
-   {
-      return flights;
-   }
-</pre>
-</p><p>
-The <tt>mappedBy</tt> attribute specifies which side of the relationship is responsible for managing the relationship.  If it is not set, then that side is responsible.
-So, for this example, the <tt>Flight</tt> Entity is responsible for managing the relation.
-In this example, we are specifying multiple <tt>inverseJoinColumns</tt> because Customer has a composite primary key.
-</p><p>
-Let's look at the other side of the relationship in Flight.
-</p><p>
-<pre>
-   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
-   @JoinTable(name = "flight_customer_table",
-              joinColumns = {@JoinColumn(name = "FLIGHT_ID")},
-              inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
-   public Set&lt;Customer&gt; getCustomers()
-   {
-      return customers;
-   }
-</pre>
-</p><p>
-The <tt>Flight</tt> Entity must also define the <tt>@ManyToMany</tt> and <tt>@JoinTable</tt>.
-</p><p>
-The database associate table will look like this:
-</p><p>
-<pre>
-   create table FLIGHT_CUSTOMER_TABLE (
-      CUSTOMER_ID integer,
-      CUSTOMER_NAME varchar,
-      FLIGHT_ID integer
-   );
-</pre>
-</p><p>
-<h4>Building and Running</h4>
-
-To build and run the example, make sure you have <tt>ejb3.deployer</tt> installed in JBoss 4.0.x and have JBoss running.  See the reference manual on how to install EJB 3.0.  
-<pre>
-Unix:    $ export JBOSS_HOME=&lt;where your jboss 4.0 distribution is&gt;
-Windows: $ set JBOSS_HOME=&lt;where your jboss 4.0 distribution is&gt;
-$ ant
-$ ant run
-
-run:
-     [java] 2004-10-07 14:39:23,103 INFO org.jboss.remoting.InvokerRegistry[main] - Failed to load soap remoting transpo
-rt: org/apache/axis/AxisFault
-     [java] Air France customers
-     [java] Bill
-     [java] Monica
-     [java] USAir customers
-     [java] Molly
-</pre>
-</p><p>
-The INFO message you can ignore.  It will be fixed in later releases of JBoss 4.0.
-</p><p>
-<h4>View the tables and rows</h4>
-
-You can view the tables created by JBoss by going to the <a href="http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DHypersonic%2Cdatabase%3DlocalDB">Hypersonic SQL service</a>, scrolling down to the <tt>startDatabaseManager</tt> button and clicking it.  A Hypersonic SQL window will be minimized, but you can open it up to look at the tables and do queries.
-</p><p>
-</p>
-</body>
-</html>

Copied: projects/ejb3/trunk/docs/tutorial/composite/composite.html (from rev 82494, projects/oldstuff/ejb3/docs/tutorial/composite/composite.html)
===================================================================
--- projects/ejb3/trunk/docs/tutorial/composite/composite.html	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/composite/composite.html	2008-12-23 10:46:15 UTC (rev 82505)
@@ -0,0 +1,157 @@
+<html>
+<body>
+<p>
+<h2>Composite Primary Keys and Primary Key Classes</h2>
+
+The EJB 3.0 specification allows you to define a primary key class as a @Embeddable and use it as the primary key of your Entity bean.  One or
+more properties can be used as members of the primary key for that particular table.  This tutorial is an adaptation of the
+<i>relationships</i> tutorial.  It adds a primary key class to Customer that holds both the <i>name</i> and <i>id</i> of the Customer.
+</p><p>
+<pre>
+ at Embeddable
+public class CustomerPK implements java.io.Serializable
+{
+   private long id;
+   private String name;
+
+
+   public CustomerPK()
+   {
+   }
+
+   public CustomerPK(long id, String name)
+   {
+      this.id = id;
+      this.name = name;
+   }
+
+   public long getId()
+   {
+      return id;
+   }
+
+   public void setId(long id)
+   {
+      this.id = id;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public int hashCode()
+   {
+      return (int) id + name.hashCode();
+   }
+
+   public boolean equals(Object obj)
+   {
+      if (obj == this) return true;
+      if (!(obj instanceof CustomerPK)) return false;
+      if (obj == null) return false;
+      CustomerPK pk = (CustomerPK) obj;
+      return pk.id == id &amp;&amp; pk.name.equals(name);
+   }
+}
+</pre>
+</p><p>
+<h4>Mapping the primary key class</h4>
+
+Open up <a href="src/org/jboss/tutorial/composite/bean/Customer.java">Customer</a> and look for the <tt>getPk()</tt> method.  This
+defines the primary key class.
+</p><p>
+<pre>
+   @EmbeddedId
+   public CustomerPK getPk()
+   {
+      return pk;
+   }
+</pre>
+</p><p>
+The <a href="src/org/jboss/tutorial/composite/bean/CustomerPK.java">CustomerPK</a> class is mapped to <a href="src/org/jboss/tutorial/composite/bean/Customer.java">Customer</a>
+just like any other embeddable object.  The additional <tt>@EmbeddedId</tt> annotation specifies that it will be the primary key.
+NOTE: If you provide a primary key class, JBoss cannot autogenerate the key
+for you.  You must allocate a CustomerPK class and instantiate it with your id and name when you create the Customer.
+</p><p>
+</p><p>
+<h4>Many To Many</h4>
+
+There is a mant to many relationship between <a href="src/org/jboss/tutorial/composite/bean/Customer.java">Customer</a> and <a href="src/org/jboss/tutorial/composite/bean/Flight.java">Flight</a>.
+  In order to have a many to many relationship there needs to be a distinct join table that maps the many to many relationship.  This is called an association table.
+  You need to use the <tt>@JoinTable</tt> annotation to define this join table.
+  The <tt>@JoinTable</tt> must be defined on both sides of the bi-directional relationship.  Let's look at the Customer side of the relationship
+</p><p>
+<pre>
+   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers")
+   @JoinTable(name="flight_customer_table",
+              joinColumns={@JoinColumn(name = "FLIGHT_ID")},
+              inverseJoinColumns={@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
+   public Set&lt;Flight&gt; getFlights()
+   {
+      return flights;
+   }
+</pre>
+</p><p>
+The <tt>mappedBy</tt> attribute specifies which side of the relationship is responsible for managing the relationship.  If it is not set, then that side is responsible.
+So, for this example, the <tt>Flight</tt> Entity is responsible for managing the relation.
+In this example, we are specifying multiple <tt>inverseJoinColumns</tt> because Customer has a composite primary key.
+</p><p>
+Let's look at the other side of the relationship in Flight.
+</p><p>
+<pre>
+   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
+   @JoinTable(name = "flight_customer_table",
+              joinColumns = {@JoinColumn(name = "FLIGHT_ID")},
+              inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
+   public Set&lt;Customer&gt; getCustomers()
+   {
+      return customers;
+   }
+</pre>
+</p><p>
+The <tt>Flight</tt> Entity must also define the <tt>@ManyToMany</tt> and <tt>@JoinTable</tt>.
+</p><p>
+The database associate table will look like this:
+</p><p>
+<pre>
+   create table FLIGHT_CUSTOMER_TABLE (
+      CUSTOMER_ID integer,
+      CUSTOMER_NAME varchar,
+      FLIGHT_ID integer
+   );
+</pre>
+</p><p>
+<h4>Building and Running</h4>
+
+To build and run the example, make sure you have <tt>ejb3.deployer</tt> installed in JBoss 4.0.x and have JBoss running.  See the reference manual on how to install EJB 3.0.  
+<pre>
+Unix:    $ export JBOSS_HOME=&lt;where your jboss 4.0 distribution is&gt;
+Windows: $ set JBOSS_HOME=&lt;where your jboss 4.0 distribution is&gt;
+$ ant
+$ ant run
+
+run:
+     [java] 2004-10-07 14:39:23,103 INFO org.jboss.remoting.InvokerRegistry[main] - Failed to load soap remoting transpo
+rt: org/apache/axis/AxisFault
+     [java] Air France customers
+     [java] Bill
+     [java] Monica
+     [java] USAir customers
+     [java] Molly
+</pre>
+</p><p>
+The INFO message you can ignore.  It will be fixed in later releases of JBoss 4.0.
+</p><p>
+<h4>View the tables and rows</h4>
+
+You can view the tables created by JBoss by going to the <a href="http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DHypersonic%2Cdatabase%3DlocalDB">Hypersonic SQL service</a>, scrolling down to the <tt>startDatabaseManager</tt> button and clicking it.  A Hypersonic SQL window will be minimized, but you can open it up to look at the tables and do queries.
+</p><p>
+</p>
+</body>
+</html>

Deleted: projects/ejb3/trunk/docs/tutorial/composite/composite.wiki
===================================================================
--- projects/oldstuff/ejb3/docs/tutorial/composite/composite.wiki	2008-12-04 08:31:45 UTC (rev 82032)
+++ projects/ejb3/trunk/docs/tutorial/composite/composite.wiki	2008-12-23 10:46:15 UTC (rev 82505)
@@ -1,146 +0,0 @@
-!!!Composite Primary Keys and Primary Key Classes
-The EJB 3.0 specification allows you to define a primary key class as a @Embeddable and use it as the primary key of your Entity bean.  One or
-more properties can be used as members of the primary key for that particular table.  This tutorial is an adaptation of the
-''relationships'' tutorial.  It adds a primary key class to Customer that holds both the ''name'' and ''id'' of the Customer.
-
-{{{
- at Embeddable
-public class CustomerPK implements java.io.Serializable
-{
-   private long id;
-   private String name;
-
-
-   public CustomerPK()
-   {
-   }
-
-   public CustomerPK(long id, String name)
-   {
-      this.id = id;
-      this.name = name;
-   }
-
-   public long getId()
-   {
-      return id;
-   }
-
-   public void setId(long id)
-   {
-      this.id = id;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public int hashCode()
-   {
-      return (int) id + name.hashCode();
-   }
-
-   public boolean equals(Object obj)
-   {
-      if (obj == this) return true;
-      if (!(obj instanceof CustomerPK)) return false;
-      if (obj == null) return false;
-      CustomerPK pk = (CustomerPK) obj;
-      return pk.id == id && pk.name.equals(name);
-   }
-}
-}}}
-
-!Mapping the primary key class
-Open up [Customer|src/org/jboss/tutorial/composite/bean/Customer.java] and look for the {{getPk()}} method.  This
-defines the primary key class.
-
-{{{
-   @EmbeddedId
-   public CustomerPK getPk()
-   {
-      return pk;
-   }
-}}}
-
-The [CustomerPK|src/org/jboss/tutorial/composite/bean/CustomerPK.java] class is mapped to [Customer|src/org/jboss/tutorial/composite/bean/Customer.java]
-just like any other embeddable object.  The additional {{@EmbeddedId}} annotation specifies that it will be the primary key.
-NOTE: If you provide a primary key class, JBoss cannot autogenerate the key
-for you.  You must allocate a CustomerPK class and instantiate it with your id and name when you create the Customer.
-
-
-!Many To Many
-There is a mant to many relationship between [Customer|src/org/jboss/tutorial/composite/bean/Customer.java] and [Flight|src/org/jboss/tutorial/composite/bean/Flight.java].
-  In order to have a many to many relationship there needs to be a distinct join table that maps the many to many relationship.  This is called an association table.
-  You need to use the {{@JoinTable}} annotation to define this join table.
-  The {{@JoinTable}} must be defined on both sides of the bi-directional relationship.  Let's look at the Customer side of the relationship
-
-{{{
-   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers")
-   @JoinTable(name="flight_customer_table",
-              joinColumns={@JoinColumn(name = "FLIGHT_ID")},
-              inverseJoinColumns={@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
-   public Set<Flight> getFlights()
-   {
-      return flights;
-   }
-}}}
-
-The {{mappedBy}} attribute specifies which side of the relationship is responsible for managing the relationship.  If it is not set, then that side is responsible.
-So, for this example, the {{Flight}} Entity is responsible for managing the relation.
-In this example, we are specifying multiple {{inverseJoinColumns}} because Customer has a composite primary key.
-
-Let's look at the other side of the relationship in Flight.
-
-{{{
-   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
-   @JoinTable(name = "flight_customer_table",
-              joinColumns = {@JoinColumn(name = "FLIGHT_ID")},
-              inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
-   public Set<Customer> getCustomers()
-   {
-      return customers;
-   }
-}}}
-
-The {{Flight}} Entity must also define the {{@ManyToMany}} and {{@JoinTable}}.
-
-The database associate table will look like this:
-
-{{{
-   create table FLIGHT_CUSTOMER_TABLE (
-      CUSTOMER_ID integer,
-      CUSTOMER_NAME varchar,
-      FLIGHT_ID integer
-   );
-}}}
-
-!Building and Running
-To build and run the example, make sure you have {{ejb3.deployer}} installed in JBoss 4.0.x and have JBoss running.  See the reference manual on how to install EJB 3.0.  
-{{{
-Unix:    $ export JBOSS_HOME=<where your jboss 4.0 distribution is>
-Windows: $ set JBOSS_HOME=<where your jboss 4.0 distribution is>
-$ ant
-$ ant run
-
-run:
-     [java] 2004-10-07 14:39:23,103 INFO org.jboss.remoting.InvokerRegistry[main] - Failed to load soap remoting transpo
-rt: org/apache/axis/AxisFault
-     [java] Air France customers
-     [java] Bill
-     [java] Monica
-     [java] USAir customers
-     [java] Molly
-}}}
-
-The INFO message you can ignore.  It will be fixed in later releases of JBoss 4.0.
-
-!View the tables and rows
-You can view the tables created by JBoss by going to the [Hypersonic SQL service|http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DHypersonic%2Cdatabase%3DlocalDB], scrolling down to the {{startDatabaseManager}} button and clicking it.  A Hypersonic SQL window will be minimized, but you can open it up to look at the tables and do queries.
-

Copied: projects/ejb3/trunk/docs/tutorial/composite/composite.wiki (from rev 82494, projects/oldstuff/ejb3/docs/tutorial/composite/composite.wiki)
===================================================================
--- projects/ejb3/trunk/docs/tutorial/composite/composite.wiki	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/composite/composite.wiki	2008-12-23 10:46:15 UTC (rev 82505)
@@ -0,0 +1,146 @@
+!!!Composite Primary Keys and Primary Key Classes
+The EJB 3.0 specification allows you to define a primary key class as a @Embeddable and use it as the primary key of your Entity bean.  One or
+more properties can be used as members of the primary key for that particular table.  This tutorial is an adaptation of the
+''relationships'' tutorial.  It adds a primary key class to Customer that holds both the ''name'' and ''id'' of the Customer.
+
+{{{
+ at Embeddable
+public class CustomerPK implements java.io.Serializable
+{
+   private long id;
+   private String name;
+
+
+   public CustomerPK()
+   {
+   }
+
+   public CustomerPK(long id, String name)
+   {
+      this.id = id;
+      this.name = name;
+   }
+
+   public long getId()
+   {
+      return id;
+   }
+
+   public void setId(long id)
+   {
+      this.id = id;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public int hashCode()
+   {
+      return (int) id + name.hashCode();
+   }
+
+   public boolean equals(Object obj)
+   {
+      if (obj == this) return true;
+      if (!(obj instanceof CustomerPK)) return false;
+      if (obj == null) return false;
+      CustomerPK pk = (CustomerPK) obj;
+      return pk.id == id && pk.name.equals(name);
+   }
+}
+}}}
+
+!Mapping the primary key class
+Open up [Customer|src/org/jboss/tutorial/composite/bean/Customer.java] and look for the {{getPk()}} method.  This
+defines the primary key class.
+
+{{{
+   @EmbeddedId
+   public CustomerPK getPk()
+   {
+      return pk;
+   }
+}}}
+
+The [CustomerPK|src/org/jboss/tutorial/composite/bean/CustomerPK.java] class is mapped to [Customer|src/org/jboss/tutorial/composite/bean/Customer.java]
+just like any other embeddable object.  The additional {{@EmbeddedId}} annotation specifies that it will be the primary key.
+NOTE: If you provide a primary key class, JBoss cannot autogenerate the key
+for you.  You must allocate a CustomerPK class and instantiate it with your id and name when you create the Customer.
+
+
+!Many To Many
+There is a mant to many relationship between [Customer|src/org/jboss/tutorial/composite/bean/Customer.java] and [Flight|src/org/jboss/tutorial/composite/bean/Flight.java].
+  In order to have a many to many relationship there needs to be a distinct join table that maps the many to many relationship.  This is called an association table.
+  You need to use the {{@JoinTable}} annotation to define this join table.
+  The {{@JoinTable}} must be defined on both sides of the bi-directional relationship.  Let's look at the Customer side of the relationship
+
+{{{
+   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers")
+   @JoinTable(name="flight_customer_table",
+              joinColumns={@JoinColumn(name = "FLIGHT_ID")},
+              inverseJoinColumns={@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
+   public Set<Flight> getFlights()
+   {
+      return flights;
+   }
+}}}
+
+The {{mappedBy}} attribute specifies which side of the relationship is responsible for managing the relationship.  If it is not set, then that side is responsible.
+So, for this example, the {{Flight}} Entity is responsible for managing the relation.
+In this example, we are specifying multiple {{inverseJoinColumns}} because Customer has a composite primary key.
+
+Let's look at the other side of the relationship in Flight.
+
+{{{
+   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
+   @JoinTable(name = "flight_customer_table",
+              joinColumns = {@JoinColumn(name = "FLIGHT_ID")},
+              inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
+   public Set<Customer> getCustomers()
+   {
+      return customers;
+   }
+}}}
+
+The {{Flight}} Entity must also define the {{@ManyToMany}} and {{@JoinTable}}.
+
+The database associate table will look like this:
+
+{{{
+   create table FLIGHT_CUSTOMER_TABLE (
+      CUSTOMER_ID integer,
+      CUSTOMER_NAME varchar,
+      FLIGHT_ID integer
+   );
+}}}
+
+!Building and Running
+To build and run the example, make sure you have {{ejb3.deployer}} installed in JBoss 4.0.x and have JBoss running.  See the reference manual on how to install EJB 3.0.  
+{{{
+Unix:    $ export JBOSS_HOME=<where your jboss 4.0 distribution is>
+Windows: $ set JBOSS_HOME=<where your jboss 4.0 distribution is>
+$ ant
+$ ant run
+
+run:
+     [java] 2004-10-07 14:39:23,103 INFO org.jboss.remoting.InvokerRegistry[main] - Failed to load soap remoting transpo
+rt: org/apache/axis/AxisFault
+     [java] Air France customers
+     [java] Bill
+     [java] Monica
+     [java] USAir customers
+     [java] Molly
+}}}
+
+The INFO message you can ignore.  It will be fixed in later releases of JBoss 4.0.
+
+!View the tables and rows
+You can view the tables created by JBoss by going to the [Hypersonic SQL service|http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DHypersonic%2Cdatabase%3DlocalDB], scrolling down to the {{startDatabaseManager}} button and clicking it.  A Hypersonic SQL window will be minimized, but you can open it up to look at the tables and do queries.
+

Deleted: projects/ejb3/trunk/docs/tutorial/composite/jndi.properties
===================================================================
--- projects/oldstuff/ejb3/docs/tutorial/composite/jndi.properties	2008-12-04 08:31:45 UTC (rev 82032)
+++ projects/ejb3/trunk/docs/tutorial/composite/jndi.properties	2008-12-23 10:46:15 UTC (rev 82505)
@@ -1,3 +0,0 @@
-java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
-java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
-java.naming.provider.url=localhost

Copied: projects/ejb3/trunk/docs/tutorial/composite/jndi.properties (from rev 82494, projects/oldstuff/ejb3/docs/tutorial/composite/jndi.properties)
===================================================================
--- projects/ejb3/trunk/docs/tutorial/composite/jndi.properties	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/composite/jndi.properties	2008-12-23 10:46:15 UTC (rev 82505)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=localhost

Deleted: projects/ejb3/trunk/docs/tutorial/composite/log4j.xml
===================================================================
--- projects/oldstuff/ejb3/docs/tutorial/composite/log4j.xml	2008-12-04 08:31:45 UTC (rev 82032)
+++ projects/ejb3/trunk/docs/tutorial/composite/log4j.xml	2008-12-23 10:46:15 UTC (rev 82505)
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<!-- ===================================================================== -->
-<!--                                                                       -->
-<!--  Log4j Configuration                                                  -->
-<!--                                                                       -->
-<!-- ===================================================================== -->
-
-<!-- $Id$ -->
-
-<!--
-   | For more configuration infromation and examples see the Jakarta Log4j
-   | owebsite: http://jakarta.apache.org/log4j
- -->
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
-   
-<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
-      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
-      <param name="Target" value="System.out"/>
-      <param name="Threshold" value="INFO"/>
-
-      <layout class="org.apache.log4j.PatternLayout">
-         <!-- The default pattern: Date Priority [Category] Messagen -->
-         <!--
-         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
-         -->
-         <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L)  -%m%n"/>
-      </layout>
-</appender>
-
-   <root>
-      <appender-ref ref="CONSOLE"/>
-   </root>
-
-</log4j:configuration>

Copied: projects/ejb3/trunk/docs/tutorial/composite/log4j.xml (from rev 82494, projects/oldstuff/ejb3/docs/tutorial/composite/log4j.xml)
===================================================================
--- projects/ejb3/trunk/docs/tutorial/composite/log4j.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/composite/log4j.xml	2008-12-23 10:46:15 UTC (rev 82505)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id$ -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+   
+<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+      <param name="Target" value="System.out"/>
+      <param name="Threshold" value="INFO"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Messagen -->
+         <!--
+         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+         -->
+         <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L)  -%m%n"/>
+      </layout>
+</appender>
+
+   <root>
+      <appender-ref ref="CONSOLE"/>
+   </root>
+
+</log4j:configuration>

Copied: projects/ejb3/trunk/docs/tutorial/composite/src (from rev 82494, projects/oldstuff/ejb3/docs/tutorial/composite/src)




More information about the jboss-cvs-commits mailing list