[jboss-svn-commits] JBL Code SVN: r26158 - in labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects: .settings and 32 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Apr 20 13:01:38 EDT 2009


Author: whitingjr
Date: 2009-04-20 13:01:38 -0400 (Mon, 20 Apr 2009)
New Revision: 26158

Added:
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.classpath
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.project
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/org.hibernate.eclipse.console.prefs
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/org.maven.ide.eclipse.prefs
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/pom.xml
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/BillingDetailsDAO.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/CategoryDAO.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/GenericDAO.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ItemDAO.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/UserDAO.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/BillingDetailsDAOBean.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/CategoryDAOBean.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/GenericEJB3DAO.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/ItemDAOBean.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/UserDAOBean.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/BusinessException.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/PermissionException.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Address.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/AddressEntity.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Auditable.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BankAccount.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Bid.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BillingDetails.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItem.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItemComponent.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Category.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Comment.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCard.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCardType.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Item.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ItemState.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/MonetaryAmount.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Rating.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Shipment.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ShipmentState.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/User.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountCompositeUserType.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountSimpleUserType.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountType.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/package-info.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/EJB3IntegrationTest.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/FixDBUnit.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/TestUtil.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basedata.xml
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basic/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basic/PersistentStateTransitions.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/AbstractMVCCEvent.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/MVCCLoadEventListener.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/MVCCSaveOrUpdateEvent.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCTransaction.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/SessionMapper.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/HandleUtils.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/MappingHandles.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/MappingSessionMVCC.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/model/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/model/CompositeObjectHandle.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mvcc/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mvcc/dao/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/Mapping.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/TransactionWorkspace.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/util/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/util/HibernateUtil.java
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/caveatemptor-beans.xml
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/persistence.xml
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/basedata.xml
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/data/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/default.persistence.properties
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/ejb3-interceptors-aop.xml
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/embedded-jboss-beans.xml
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/jndi.properties
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/log4j.properties
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/java/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/java/uk/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/java/uk/ac/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/java/uk/ac/ncl/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/java/uk/ac/ncl/sdia/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/java/uk/ac/ncl/sdia/a8905943/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/java/uk/ac/ncl/sdia/a8905943/event/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/test/java/uk/ac/ncl/sdia/a8905943/util/
   labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/target/
Log:
First cut of MVCC implementation. It's not pretty and references are not thread safe.

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.classpath
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.classpath	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.classpath	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="lib" path="/caveatemptor/lib/jboss-ejb3-all.jar" sourcepath="/home/whitingjr/eclipse/workspaces/red-hat/thirdparty/org/jboss/javaee/lib/jboss-ejb-api-sources.jar"/>
+	<classpathentry kind="var" path="hibernate-home/hibernate-entitymanager-3.3.2.GA/hibernate-entitymanager.jar" sourcepath="/hibernate-home/hibernate-entitymanager-3.3.2.GA/src"/>
+	<classpathentry kind="var" path="hibernate-home/hibernate-annotations-3.3.1.GA/hibernate-annotations.jar" sourcepath="/hibernate-home/hibernate-annotations-3.3.1.GA/src"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/multiverse"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.project
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.project	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.project	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>HibernateWithInMemoryObjects</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/org.hibernate.eclipse.console.prefs
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/org.hibernate.eclipse.console.prefs	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/org.hibernate.eclipse.console.prefs	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,4 @@
+#Mon Apr 20 15:31:41 BST 2009
+default.configuration=
+eclipse.preferences.version=1
+hibernate3.enabled=false

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/.settings/org.maven.ide.eclipse.prefs	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,9 @@
+#Thu Apr 09 09:47:47 BST 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/pom.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/pom.xml	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/pom.xml	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,56 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>HibernateWithInMemoryObjects</groupId>
+	<artifactId>HibernateWithInMemoryObjects</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<dependencies>
+		<dependency>
+			<groupId>org.codehaus</groupId>
+			<artifactId>multiverse</artifactId>
+			<version>0.0.1-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-collections</groupId>
+			<artifactId>commons-collections</artifactId>
+			<version>3.2.1</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.4</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.4</version>
+		</dependency>
+		<dependency>
+			<groupId>org.dbunit</groupId>
+			<artifactId>dbunit</artifactId>
+			<version>2.4.4</version>
+		</dependency>
+		<dependency>
+			<groupId>org.testng</groupId>
+			<artifactId>testng</artifactId>
+			<version>5.6</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<version>1.0.4</version>
+		</dependency>
+		<dependency>
+			<groupId>org.hibernate</groupId>
+			<artifactId>hibernate</artifactId>
+			<version>3.2.6.ga</version>
+		</dependency>
+		
+<dependency>
+  <groupId>javax.persistence</groupId>
+  <artifactId>persistence-api</artifactId>
+  <version>1.0</version>
+</dependency>
+
+	</dependencies>
+</project>
\ No newline at end of file

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/BillingDetailsDAO.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/BillingDetailsDAO.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/BillingDetailsDAO.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,20 @@
+package auction.dao;
+
+import auction.model.*;
+
+import java.util.*;
+
+/**
+ * Business DAO operations related to the <tt>BillingDetails</tt> entity.
+ * <p>
+ * @see auction.model.BillingDetails
+ * @see auction.model.CreditCard
+ * @see auction.model.BankAccount
+ *
+ * @author Christian Bauer
+ */
+public interface BillingDetailsDAO extends GenericDAO<BillingDetails, Long> {
+
+    public List<BillingDetails> findConcrete(Class concreteClass);
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/BillingDetailsDAO.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/CategoryDAO.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/CategoryDAO.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/CategoryDAO.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,19 @@
+package auction.dao;
+
+
+import auction.model.Category;
+
+import java.util.List;
+
+/**
+ * Business DAO operations related to the <tt>Category</tt> entity.
+ *
+ * @see auction.model.Category
+ *
+ * @author Christian Bauer
+ */
+public interface CategoryDAO extends GenericDAO<Category, Long> {
+
+    public List<Category> findAll(boolean onlyRootCategories);
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/CategoryDAO.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/GenericDAO.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/GenericDAO.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/GenericDAO.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,30 @@
+package auction.dao;
+
+import java.util.List;
+import java.io.Serializable;
+
+/**
+ * An interface shared by all business data access objects.
+ * <p>
+ * All CRUD (create, read, update, delete) basic data access operations are
+ * isolated in this interface and shared accross all DAO implementations.
+ * The current design is for a state-management oriented persistence layer
+ * (for example, there is no UDPATE statement function) that provides
+ * automatic transactional dirty checking of business objects in persistent
+ * state.
+ *
+ * @author Christian Bauer
+ */
+public interface GenericDAO<T, ID extends Serializable> {
+
+    T findById(ID id, boolean lock);
+
+    List<T> findAll();
+
+    List<T> findByExample(T exampleInstance, String... excludeProperty);
+
+    T makePersistent(T entity);
+
+    void makeTransient(T entity);
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/GenericDAO.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ItemDAO.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ItemDAO.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ItemDAO.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,26 @@
+package auction.dao;
+
+import auction.model.Item;
+import auction.model.Bid;
+
+
+/**
+ * Business DAO operations related to the <tt>Item</tt> entity.
+ * <p>
+ * Note the usage of the constants for named query declaration. That way,
+ * naming of queries is centralized and checked at compile time. Of course,
+ * this can be broken by externalizing queries into XML metadata, but it
+ * is type-safe for queries declared in annotations. See the entity class
+ * source for an example.
+ *
+ * @see auction.model.Item
+ *
+ * @author Christian Bauer
+ */
+public interface ItemDAO extends GenericDAO<Item, Long> {
+
+    Bid getMaxBid(Item item);
+    Bid getMinBid(Item item);
+    public Item fetchWithBids(Item item);
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ItemDAO.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/UserDAO.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/UserDAO.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/UserDAO.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,13 @@
+package auction.dao;
+
+import auction.model.User;
+
+
+/**
+ * Business DAO operations related to the <tt>User</tt> entity.
+ *
+ * @see auction.model.User
+ *
+ * @author Christian Bauer
+ */
+public interface UserDAO extends GenericDAO<User, Long> { }


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/UserDAO.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/BillingDetailsDAOBean.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/BillingDetailsDAOBean.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/BillingDetailsDAOBean.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,26 @@
+package auction.dao.ejb3;
+
+import auction.dao.BillingDetailsDAO;
+import auction.model.BillingDetails;
+
+import javax.ejb.*;
+import java.util.*;
+
+/**
+ * EJB3-specific implementation of the <tt>CategoryDAO</tt> non-CRUD data access object.
+ *
+ * @author Christian Bauer
+ */
+
+ at Stateless
+ at TransactionAttribute(TransactionAttributeType.REQUIRED)
+public class BillingDetailsDAOBean
+        extends     GenericEJB3DAO<BillingDetails, Long>
+        implements  BillingDetailsDAO {
+
+    @SuppressWarnings("unchecked")
+    public List<BillingDetails> findConcrete(Class concreteClass) {
+        return getEntityManager()
+                .createQuery("select c from " + concreteClass.getName() + " c").getResultList();
+    }
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/BillingDetailsDAOBean.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/CategoryDAOBean.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/CategoryDAOBean.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/CategoryDAOBean.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,30 @@
+package auction.dao.ejb3;
+
+import auction.dao.CategoryDAO;
+import auction.model.Category;
+
+import javax.ejb.*;
+import java.util.List;
+
+/**
+ * EJB 3.0 implementation of the <tt>CategoryDAO</tt> non-CRUD data access object.
+ *
+ * @author Christian Bauer
+ */
+ at Stateless
+ at TransactionAttribute(TransactionAttributeType.REQUIRED)
+public class CategoryDAOBean
+        extends     GenericEJB3DAO<Category, Long>
+        implements  CategoryDAO {
+
+    @SuppressWarnings("unchecked")
+    public List<Category> findAll(boolean onlyRootCategories) {
+        if (onlyRootCategories)
+            return getEntityManager().createQuery("select c from "+ getEntityBeanType().getName() + " c" +
+                                                  " where c.parentCategory is null").getResultList();
+            // Or bind ourself to a Hibernate extension and use findByCriteria(Criterion...) from superclass?
+        else
+            return findAll();
+    } 
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/CategoryDAOBean.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/GenericEJB3DAO.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/GenericEJB3DAO.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/GenericEJB3DAO.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,117 @@
+package auction.dao.ejb3;
+
+import javax.persistence.*;
+import java.util.*;
+import java.io.Serializable;
+import java.lang.reflect.ParameterizedType;
+
+import auction.dao.GenericDAO;
+
+/**
+ * Implements the generic CRUD data access operations using Java Persistence APIs.
+ * <p>
+ * To write a DAO, subclass and parameterize this class with your entity.
+ * Of course, assuming that you have a traditional 1:1 appraoch for
+ * Entity:DAO design. This is actually an implementation that uses some
+ * extensions for Java Persistence from Hibernate - you can see how the
+ * packages for the extensions are not imported, but named inline.
+ *
+ * @author Christian Bauer
+ */
+public abstract class GenericEJB3DAO<T,ID extends Serializable>
+        implements GenericDAO<T, ID> {
+
+    private Class<T> entityBeanType;
+
+    private EntityManager em;
+
+    public GenericEJB3DAO() {
+        this.entityBeanType = (Class<T>) ((ParameterizedType) getClass()
+                                .getGenericSuperclass()).getActualTypeArguments()[0];
+    }
+
+    // If this DAO is wired in as a Seam component, Seam injects the right persistence context
+    // if a method on this DAO is called. If the caller is a conversational stateful component,
+    // the persistence context will be scoped to the conversation, not to the method call.
+    // You can call this method and set the EntityManager manually, in an integration test.
+    @PersistenceContext
+    public void setEntityManager(EntityManager em) {
+        this.em = em;
+    }
+
+    protected EntityManager getEntityManager() {
+        if (em == null)
+            throw new IllegalStateException("EntityManager has not been set on DAO before usage");
+        return em;
+    }
+
+    public Class<T> getEntityBeanType() {
+        return entityBeanType;
+    }
+
+    public T findById(ID id, boolean lock) {
+        T entity;
+        if (lock) {
+            entity = getEntityManager().find(getEntityBeanType(), id);
+            em.lock(entity, javax.persistence.LockModeType.WRITE);
+        } else {
+            entity = getEntityManager().find(getEntityBeanType(), id);
+        }
+        return entity;
+    }
+
+    @SuppressWarnings("unchecked")
+    public List<T> findAll() {
+        return getEntityManager().createQuery("from " + getEntityBeanType().getName() ).getResultList();
+    }
+
+
+    @SuppressWarnings("unchecked")
+    public List<T> findByExample(T exampleInstance, String... excludeProperty) {
+        // Using Hibernate, more difficult with EntityManager and EJB-QL
+        org.hibernate.Criteria crit = ((org.hibernate.ejb.HibernateEntityManager)getEntityManager())
+                            .getSession()
+                            .createCriteria(getEntityBeanType());
+        org.hibernate.criterion.Example example =
+                org.hibernate.criterion.Example.create(exampleInstance);
+        for (String exclude : excludeProperty) {
+            example.excludeProperty(exclude);
+        }
+        crit.add(example);
+        return crit.list();
+    }
+
+    public T makePersistent(T entity) {
+        return getEntityManager().merge(entity);
+    }
+
+    public void makeTransient(T entity) {
+        getEntityManager().remove(entity);
+    }
+
+    public void flush() {
+        getEntityManager().flush();
+    }
+
+    public void clear() {
+        getEntityManager().clear();
+    }
+
+    /**
+     * Use this inside subclasses as a convenience method.
+     */
+    @SuppressWarnings("unchecked")
+    protected List<T> findByCriteria(org.hibernate.criterion.Criterion... criterion) {
+        // Using Hibernate, more difficult with EntityManager and EJB-QL
+        org.hibernate.Session session =
+                ((org.hibernate.ejb.HibernateEntityManager)getEntityManager()).getSession();
+        org.hibernate.Criteria crit
+                = session.createCriteria(getEntityBeanType());
+        for (org.hibernate.criterion.Criterion c : criterion) {
+            crit.add(c);
+        }
+        return crit.list();
+   }
+
+}
+


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/GenericEJB3DAO.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/ItemDAOBean.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/ItemDAOBean.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/ItemDAOBean.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,49 @@
+package auction.dao.ejb3;
+
+import auction.model.Bid;
+import auction.model.Item;
+import auction.dao.ItemDAO;
+
+import javax.ejb.*;
+
+import java.util.List;
+
+/**
+ * EJB3-specific implementation of the <tt>ItemDAO</tt> non-CRUD data access object.
+ *
+ * @author Christian Bauer
+ */
+ at Stateless
+ at TransactionAttribute(TransactionAttributeType.REQUIRED)
+public class ItemDAOBean extends GenericEJB3DAO<Item, Long> implements ItemDAO {
+
+    public Bid getMaxBid(Item item) {
+        // TODO: em.getSingleResult() doesn't return null but throws an exception, how inconvenient
+        Bid currentMaxBid = null;
+        List result = getEntityManager()
+                            .createNamedQuery("Item-getMaxBid")
+                             .setParameter("itemId", item.getId())
+                             .getResultList();
+        if (result.size() > 0) currentMaxBid = (Bid)result.get(0);
+        return currentMaxBid;
+    }
+
+    public Bid getMinBid(Item item) {
+        // TODO: em.getSingleResult() doesn't return null but throws an exception, how inconvenient
+        Bid currentMinBid = null;
+        List result = getEntityManager()
+                             .createNamedQuery("Item-getMinBid")
+                             .setParameter("itemId", item.getId())
+                             .getResultList();
+        if (result.size() > 0) currentMinBid = (Bid)result.get(0);
+        return currentMinBid;
+    }
+
+    public Item fetchWithBids(Item item) {
+        return (Item) getEntityManager()
+                .createQuery("select i from Item i left join fetch i.bids where i = :item")
+                 .setParameter("item", item)
+                 .getSingleResult();
+    }
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/ItemDAOBean.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/UserDAOBean.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/UserDAOBean.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/UserDAOBean.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,16 @@
+package auction.dao.ejb3;
+
+
+import auction.model.User;
+import auction.dao.UserDAO;
+
+import javax.ejb.*;
+
+/**
+ * EJB3-specific implementation of the <tt>UserDataAccess</tt> non-CRUD data access object.
+ *
+ * @author Christian Bauer
+ */
+ at Stateless
+ at TransactionAttribute(TransactionAttributeType.REQUIRED)
+public class UserDAOBean extends GenericEJB3DAO<User, Long> implements UserDAO { }


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/dao/ejb3/UserDAOBean.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/BusinessException.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/BusinessException.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/BusinessException.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,26 @@
+package auction.exceptions;
+
+/**
+ * This exception is used to mark business rule violations.
+ *
+ * @author Christian Bauer
+ */
+public class BusinessException
+	extends RuntimeException {
+
+	public static final String ERROR_MSG = "business_error_msg";
+
+	public BusinessException() {}
+
+	public BusinessException(String message) {
+		super(message);
+	}
+
+	public BusinessException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public BusinessException(Throwable cause) {
+		super(cause);
+	}
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/BusinessException.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/PermissionException.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/PermissionException.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/PermissionException.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,24 @@
+package auction.exceptions;
+
+/**
+ * This exception is used to mark access violations.
+ *
+ * @author Christian Bauer
+ */
+public class PermissionException
+	extends RuntimeException {
+
+	public PermissionException() {}
+
+	public PermissionException(String message) {
+		super(message);
+	}
+
+	public PermissionException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public PermissionException(Throwable cause) {
+		super(cause);
+	}
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/exceptions/PermissionException.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Address.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Address.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Address.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,86 @@
+package auction.model;
+
+import javax.persistence.Embeddable;
+import javax.persistence.Column;
+import java.io.Serializable;
+
+/**
+ * The address of a User.
+ *
+ * An instance of this class is always associated with only
+ * one <tt>User</tt> and depends on that parent objects lifecycle,
+ * it is a component. Of course, other entity classes can also
+ * embed addresses.
+ *
+ * @see User
+ * @author Christian Bauer
+ */
+ at Embeddable
+public class Address implements Serializable {
+
+    @Column(length = 255, nullable = false)
+	private String street;
+
+    @Column(length = 16, nullable = false)
+	private String zipcode;
+
+    @Column(length = 255, nullable = false)
+	private String city;
+
+	/**
+	 * No-arg constructor for JavaBean tools
+	 */
+	public Address() {}
+
+	/**
+	 * Full constructor
+	 */
+	public Address(String street, String zipcode, String city) {
+		this.street = street;
+		this.zipcode = zipcode;
+		this.city = city;
+	}
+
+	// ********************** Accessor Methods ********************** //
+
+	public String getStreet() { return street; }
+	public void setStreet(String street) { this.street = street; }
+
+	public String getZipcode() { return zipcode; }
+	public void setZipcode(String zipcode) { this.zipcode = zipcode; }
+
+	public String getCity() { return city; }
+	public void setCity(String city) { this.city = city; }
+
+	// ********************** Common Methods ********************** //
+
+	public boolean equals(Object o) {
+		if (this == o) return true;
+		if (!(o instanceof Address)) return false;
+
+		final Address address = (Address) o;
+
+		if (!city.equals(address.city)) return false;
+		if (!street.equals(address.street)) return false;
+		if (!zipcode.equals(address.zipcode)) return false;
+
+		return true;
+	}
+
+	public int hashCode() {
+		int result;
+		result = street.hashCode();
+		result = 29 * result + zipcode.hashCode();
+		result = 29 * result + city.hashCode();
+		return result;
+	}
+
+	public String toString() {
+		return  "Street: '" + getStreet() + "', " +
+				"Zipcode: '" + getZipcode() + "', " +
+				"City: '" + getCity() + "'";
+	}
+
+	// ********************** Business Methods ********************** //
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Address.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/AddressEntity.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/AddressEntity.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/AddressEntity.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,112 @@
+package auction.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+
+/**
+ * The address of a User.
+ *
+ * This entity class supports shared references, e.g. the
+ * same instance can be referenced by a User (shippingAddress)
+ * and by a Shipment (deliveryAddress).
+ *
+ * @see User
+ * @see Shipment
+ * @author Christian Bauer
+ */
+ at org.hibernate.annotations.GenericGenerator(
+    name = "userAddressSharedPKGenerator",
+    strategy ="foreign",
+    parameters = @org.hibernate.annotations.Parameter(name = "property", value = "user")
+)
+
+ at Entity
+ at Table(name = "ADDRESS")
+public class AddressEntity implements Serializable {
+
+    @Id @GeneratedValue(generator = "userAddressSharedPKGenerator")
+    @Column(name = "ADDRESS_ID")
+    // TODO: This is ignored: @org.hibernate.annotations.ForeignKey(name = "FK_ADDRESS_USERS_SHARED_PK")
+    private Long id = null;
+
+    @Version
+    @Column(name = "OBJ_VERSION")
+    private int version = 0;
+
+    @Column(name = "STREET", length = 255, nullable = false)
+    private String street;
+
+    @Column(name = "ZIPCODE", length = 16, nullable = false)
+    private String zipcode;
+
+    @Column(name = "CITY", length = 255, nullable = false)
+    private String city;
+
+    @OneToOne(optional = false, fetch = FetchType.LAZY)
+    @PrimaryKeyJoinColumn
+    private User user;
+
+    /**
+     * No-arg constructor for JavaBean tools
+     */
+    public AddressEntity() {}
+
+    /**
+     * Full constructor
+     */
+    public AddressEntity(String street, String zipcode, String city) {
+        this.street = street;
+        this.zipcode = zipcode;
+        this.city = city;
+    }
+
+    // ********************** Accessor Methods ********************** //
+
+    public Long getId() { return id; }
+    public void setId(Long id) { this.id = id; }
+    public int getVersion() { return version; }
+
+    public String getStreet() { return street; }
+    public void setStreet(String street) { this.street = street; }
+
+    public String getZipcode() { return zipcode; }
+    public void setZipcode(String zipcode) { this.zipcode = zipcode; }
+
+    public String getCity() { return city; }
+    public void setCity(String city) { this.city = city; }
+
+    public User getUser() { return user; }
+    public void setUser(User user) { this.user = user; }
+
+    // ********************** Common Methods ********************** //
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof AddressEntity)) return false;
+
+        final AddressEntity address = (AddressEntity) o;
+
+        if (!city.equals(address.city)) return false;
+        if (!street.equals(address.street)) return false;
+        return zipcode.equals(address.zipcode);
+
+    }
+
+    public int hashCode() {
+        int result;
+        result = street.hashCode();
+        result = 29 * result + zipcode.hashCode();
+        result = 29 * result + city.hashCode();
+        return result;
+    }
+
+    public String toString() {
+        return  "Street: '" + getStreet() + "', " +
+                "Zipcode: '" + getZipcode() + "', " +
+                "City: '" + getCity() + "'";
+    }
+
+    // ********************** Business Methods ********************** //
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/AddressEntity.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Auditable.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Auditable.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Auditable.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,11 @@
+package auction.model;
+
+/**
+ * A marker interface for auditable persistent domain classes.
+ *
+ * @author Christian Bauer
+ */
+public interface Auditable {
+
+	public Long getId();
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Auditable.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BankAccount.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BankAccount.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BankAccount.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,71 @@
+package auction.model;
+
+import javax.persistence.Entity;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Column;
+
+/**
+ * This billing strategy uses a simple bank account.
+ *
+ * @author Christian Bauer
+ */
+ at Entity
+ at DiscriminatorValue("BA")
+public class BankAccount extends BillingDetails {
+
+    @Column(name = "BA_ACCOUNT", nullable = true, length = 16)
+    private String account;
+
+    @Column(name = "BA_BANKNAME", nullable = true, length = 255)
+    private String bankname;
+
+    @Column(name = "BA_SWIFT", nullable = true, length = 15)
+    private String swift;
+
+    /**
+     * No-arg constructor for JavaBean tools
+     */
+    public BankAccount() { super(); }
+
+    /**
+     * Full constructor.
+     *
+     * @param owner
+     * @param user
+     * @param account
+     * @param bankname
+     * @param swift
+     */
+    public BankAccount(String owner, User user, String account, String bankname, String swift) {
+        super(owner, user);
+        this.account = account;
+        this.bankname = bankname;
+        this.swift = swift;
+    }
+
+    // ********************** Accessor Methods ********************** //
+
+    public String getAccount() { return account; }
+    public void setAccount(String account) { this.account = account; }
+
+    public String getBankname() { return bankname; }
+    public void setBankname(String bankname) { this.bankname = bankname; }
+
+    public String getSwift() { return swift; }
+    public void setSwift(String swift) { this.swift = swift; }
+
+    // ********************** Common Methods ********************** //
+
+    public String toString() {
+        return  "BankAccount ('" + getId() + "'), " +
+                "Account: '" + getAccount() + "'";
+    }
+
+    // ********************** Business Methods ********************** //
+
+    public boolean isValid() {
+        // TODO: Validate bank account syntax.
+        return true;
+    }
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BankAccount.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Bid.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Bid.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Bid.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,131 @@
+package auction.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * An immutable class representing one bid.
+ * <p>
+ * If the "successful" property is used in a legacy situation
+ * (see book chapter 8), it is no longer an immutable class with
+ * consequences for second-level caching.
+ * <p>
+ * Note: This legacy mapping isn't currently possible with annotations.
+ *
+ * @see Item
+ * @see User
+ * @author Christian Bauer
+ */
+ at Entity
+ at Table(name = "BID")
+ at org.hibernate.annotations.Entity(mutable = false)
+public class Bid implements Serializable, Comparable {
+
+    @Id @GeneratedValue
+    @Column(name = "BID_ID")
+    private Long id = null;
+
+    @org.hibernate.annotations.Type(type = "monetary_amount_usd")
+    @org.hibernate.annotations.Columns( columns = {
+			@Column( name="BID_AMOUNT", length = 2, updatable = false),
+			@Column( name="BID_AMOUNT_CURRENCY", length = 3, updatable = false)
+        }
+	)
+    private MonetaryAmount amount;
+
+    @ManyToOne
+    @JoinColumn(name = "ITEM_ID", nullable = false, updatable = false, insertable = false)
+    @org.hibernate.annotations.ForeignKey(name="FK_ITEM_ID")
+	private Item item;
+
+    @ManyToOne
+    @JoinColumn(name = "BIDDER_ID", nullable = false, updatable = false)
+    @org.hibernate.annotations.ForeignKey(name="FK_BIDDER_ID")
+    private User bidder;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name="CREATED", nullable = false, updatable = false)
+	private Date created = new Date();
+
+    // TODO: This can't be mapped in annotations, there is no <properties> grouping
+    @Transient
+    private boolean successful = false;
+
+    /**
+	 * No-arg constructor for JavaBean tools
+	 */
+	public Bid() {}
+
+	/**
+	 * Full constructor
+	 *
+	 * @param amount
+	 * @param item
+	 * @param bidder
+	 */
+
+	public Bid(MonetaryAmount amount, Item item, User bidder) {
+		this.amount = amount;
+		this.item = item;
+		this.bidder = bidder;
+	}
+
+	// ********************** Accessor Methods ********************** //
+
+	public Long getId() { return id; }
+
+	public MonetaryAmount getAmount() { return amount; }
+
+	public Item getItem() { return item; }
+
+	public User getBidder() { return bidder; }
+
+	public Date getCreated() { return created; }
+
+    public boolean isSuccessful() { return successful; }
+    public void setSuccessful(boolean successful) { this.successful = successful; }
+
+    // ********************** Common Methods ********************** //
+
+	public boolean equals(Object o) {
+		if (this == o) return true;
+		if (!(o instanceof Bid)) return false;
+
+		final Bid bid = (Bid) o;
+
+        if (! getItem().getId().equals(bid.getItem().getId())) return false;
+        if (! (created.getTime() == bid.created.getTime()) ) return false;
+
+        if (!amount.equals(bid.amount)) return false;
+
+		return true;
+	}
+
+	public int hashCode() {
+		int result;
+		result = amount.hashCode();
+		result = 29 * result + created.hashCode();
+		return result;
+	}
+
+	public String toString() {
+		return  "Bid ('" + getId() + "'), " +
+				"Created: '" + getCreated() + "' " +
+				"Amount: '" + getAmount() + "'";
+	}
+
+	public int compareTo(Object o) {
+		if (o instanceof Bid) {
+            // Don't compare Date objects! Use the time in milliseconds!
+            return Long.valueOf(this.getCreated().getTime()).compareTo(
+                    Long.valueOf( ((Bid)o).getCreated().getTime())
+                   );
+		}
+		return 0;
+	}
+
+	// ********************** Business Methods ********************** //
+
+}
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Bid.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BillingDetails.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BillingDetails.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BillingDetails.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,114 @@
+package auction.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * This is the abstract superclass for BillingDetails.
+ * <p>
+ * A BillingDetails object is always associated with a single
+ * User and depends on the lifecycle of that user. It represents
+ * one of the billing strategies the User has choosen, usually
+ * one BillingDetails is the default in a collection of many.
+ *
+ * @author Christian Bauer
+ */
+ at Entity
+ at Table(name = "BILLING_DETAILS")
+ at Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+ at DiscriminatorColumn(
+    name = "BILLING_DETAILS_TYPE",
+    discriminatorType = DiscriminatorType.STRING
+)
+public abstract class BillingDetails implements Serializable, Comparable {
+
+    @Id @GeneratedValue
+    @Column(name = "BILLING_DETAILS_ID")
+    private Long id = null;
+
+    @Version
+    @Column(name = "OBJ_VERSION")
+    private int version = 0;
+
+    @Column(name = "OWNER", nullable = false)
+    private String owner;
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "USER_ID", updatable = false)
+    @org.hibernate.annotations.ForeignKey(name = "FK_USER_ID")
+    private User user;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name="CREATED", nullable = false, updatable = false)
+	private Date created = new Date();
+
+	/**
+	 * No-arg constructor for JavaBean tools
+	 */
+	public BillingDetails() {}
+
+
+    /**
+     * Full constructor
+     */
+    protected BillingDetails(String owner, User user) {
+        this.owner = owner;
+        this.user = user;
+    }
+
+    // ********************** Accessor Methods ********************** //
+
+    public Long getId() { return id; }
+    public int getVersion() { return version; }
+
+    public String getOwner() { return owner; }
+    public void setOwner(String owner) { this.owner = owner; }
+
+    public User getUser() { return user; }
+
+	public Date getCreated() { return created; }
+
+	// ********************** Common Methods ********************** //
+
+    // TODO: This is not a very good equals() implementation
+    public boolean equals(Object o) {
+		if (this == o) return true;
+		if (!(o instanceof BillingDetails)) return false;
+
+		final BillingDetails billingDetails = (BillingDetails) o;
+
+        if (! (created.getTime() == billingDetails.created.getTime()) ) return false;
+		if (!getOwner().equals(billingDetails.getOwner())) return false;
+
+		return true;
+	}
+
+	public int hashCode() {
+		int result;
+		result = getCreated().hashCode();
+		result = 29 * result + getOwner().hashCode();
+		return result;
+	}
+
+	public int compareTo(Object o) {
+		if (o instanceof BillingDetails)
+            // Don't compare Date objects! Use the time in milliseconds!
+            return Long.valueOf(this.getCreated().getTime()).compareTo(
+                    Long.valueOf( ((BillingDetails)o).getCreated().getTime())
+                   );
+		return 0;
+	}
+
+	// ********************** Business Methods ********************** //
+
+	/**
+	 * Checks if the billing information is correct.
+	 * <p>
+	 * Check algorithm is implemented in subclasses.
+	 *
+	 * @return boolean
+	 */
+	public abstract boolean isValid();
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/BillingDetails.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItem.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItem.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItem.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,149 @@
+package auction.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * A single item in a single category, with additional information.
+ * <p>
+ * This is really a very special mapping. The CategorizedItem class
+ * represents a join table. The ER model for this is really
+ * a many-to-many association, but instead of two entities and two
+ * collections, we mapped this as two one-to-many associations between
+ * three entities. One of the motivation for this are the additional
+ * attributes on the association table (not only two FKs): username
+ * and creation date.
+ * <p>
+ * To create a new link between a Category and an Item, instantiate
+ * an object of this class using the right constructor. Note that
+ * the Category and Item have to have an identifier value, they have
+ * to be either in persistent or detached state. Transient Category
+ * and Item instances don't work.
+ *
+ * @see Category
+ * @see Item
+ * @author Christian Bauer
+ */
+ at Entity
+ at org.hibernate.annotations.Entity(mutable = false)
+ at Table(name = "CATEGORIZED_ITEM")
+public class CategorizedItem implements Serializable, Comparable {
+
+    /**
+     * Emedded composite identifier class that represents the
+     * primary key columns of the many-to-many join table.
+     */
+    @Embeddable
+    public static class Id implements Serializable {
+        @Column(name = "CATEGORY_ID")
+		private Long categoryId;
+        @Column(name = "ITEM_ID")
+		private Long itemId;
+
+        public Id() {}
+
+        public Id(Long categoryId, Long itemId) {
+			this.categoryId = categoryId;
+			this.itemId = itemId;
+		}
+
+		public boolean equals(Object o) {
+			if (o instanceof Id) {
+				Id that = (Id)o;
+				return this.categoryId.equals(that.categoryId) &&
+					   this.itemId.equals(that.itemId);
+			} else {
+				return false;
+			}
+		}
+
+		public int hashCode() {
+			return categoryId.hashCode() + itemId.hashCode();
+		}
+	}
+
+    @EmbeddedId
+	private Id id;
+
+    @Column(name = "ADDED_BY_USER", nullable = false, length = 16)
+	private String username; // This could also be a many-to-one association to User
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "ADDED_ON")
+	private Date dateAdded = new Date();
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name="ITEM_ID", insertable = false, updatable = false)
+    @org.hibernate.annotations.ForeignKey(name = "FK_CATEGORIZED_ITEM_ITEM_ID")
+    private Item item;
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name="CATEGORY_ID", insertable = false, updatable = false)
+    @org.hibernate.annotations.ForeignKey(name = "FK_CATEGORIZED_ITEM_CATEGORY_ID")
+    private Category category;
+
+	/**
+	 * No-arg constructor for JavaBean tools
+	 */
+    public CategorizedItem() {}
+
+	/**
+	 * Full constructor, the Category and Item instances have to have an
+     * identifier value, they have to be in detached or persistent state.
+     * This constructor takes care of the bidirectional relationship by
+     * adding the new instance to the collections on either side of the
+     * many-to-many association (added to the collections).
+	 */
+	public CategorizedItem(String username, Category category, Item item) {
+		this.username = username;
+
+		this.category = category;
+		this.item = item;
+
+		// Set primary key
+        this.id = new Id(category.getId(), item.getId());
+
+		// Guarantee referential integrity
+		category.getCategorizedItems().add(this);
+		item.getCategorizedItems().add(this);
+	}
+
+	// ********************** Accessor Methods ********************** //
+
+	public Id getId() { return id; }
+
+	public String getUsername() { return username; }
+	public Date getDateAdded() { return dateAdded; }
+
+	public Category getCategory() { return category; }
+	public Item getItem() { return item; }
+
+	// ********************** Common Methods ********************** //
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        final CategorizedItem that = (CategorizedItem) o;
+        return id.equals(that.id);
+    }
+
+    public int hashCode() {
+        return id.hashCode();
+    }
+
+    public int compareTo(Object o) {
+		// CategorizedItems are sorted by date
+		if (o instanceof CategorizedItem)
+			return getDateAdded().compareTo( ((CategorizedItem)o).getDateAdded() );
+		return 0;
+	}
+
+	public String toString() {
+		return  "Added by: '" + getUsername() + "', " +
+				"On Date: '" + getDateAdded();
+	}
+
+	// ********************** Business Methods ********************** //
+
+}
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItem.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItemComponent.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItemComponent.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItemComponent.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,105 @@
+package auction.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * A single item in a single category, with additional information.
+ * <p>
+ * This is really a very special mapping. The CategorizedItemComponent
+ * class represents a join table. The ER model for this is really
+ * a many-to-many association, but instead of two entities and two
+ * collections, we mapped this as a single collection (in Category)
+ * of composite elements, instances of this class. This simplifies
+ * the lifecycle of the association. Navigation is however only
+ * possible from Category -> CategorizedItemComponent -> Item, not
+ * in the other direction.
+ *
+ * @see Category
+ * @see Item
+ * @author Christian Bauer
+ */
+ at Embeddable
+public class CategorizedItemComponent implements Serializable, Comparable {
+
+    @Column(name = "ADDED_BY_USER", nullable = false, updatable = false, length = 16)
+    private String username; // This could also be a many-to-one association to User
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "ADDED_ON", nullable = false, updatable = false)
+    private Date dateAdded = new Date();
+
+    @ManyToOne
+    @JoinColumn(name = "ITEM_ID", nullable = false, updatable = false)
+    @org.hibernate.annotations.ForeignKey(name = "FK_CATEGORIZED_ITEM_COMPONENT_ITEM_ID")
+    private Item item;
+
+    @org.hibernate.annotations.Parent
+    private Category category;
+
+	/**
+	 * No-arg constructor for JavaBean tools
+	 */
+    CategorizedItemComponent() {}
+
+	/**
+	 * Full constructor
+	 */
+	public CategorizedItemComponent(String username, Category category, Item item) {
+		this.username = username;
+		this.category = category;
+		this.item = item;
+	}
+
+	// ********************** Accessor Methods ********************** //
+
+    public String getUsername() { return username; }
+
+    public Date getDateAdded() { return dateAdded; }
+
+    public Item getItem() { return item; }
+
+    public Category getCategory() { return category; }
+    public void setCategory(Category category) { this.category = category; } // TODO: Hibernate requires this?
+
+    // ********************** Common Methods ********************** //
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final CategorizedItemComponent that = (CategorizedItemComponent) o;
+
+        if (!category.equals(that.category)) return false;
+        if (!dateAdded.equals(that.dateAdded)) return false;
+        if (!item.equals(that.item)) return false;
+        if (!username.equals(that.username)) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = username.hashCode();
+        result = 29 * result + dateAdded.hashCode();
+        result = 29 * result + item.hashCode();
+        result = 29 * result + category.hashCode();
+        return result;
+    }
+
+    public int compareTo(Object o) {
+		// CategorizedItems are sorted by date
+		if (o instanceof CategorizedItemComponent)
+			return getDateAdded().compareTo( ((CategorizedItemComponent)o).getDateAdded() );
+		return 0;
+	}
+
+	public String toString() {
+		return  "Added by: '" + getUsername() + "', " +
+				"On Date: '" + getDateAdded();
+	}
+
+	// ********************** Business Methods ********************** //
+
+}
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CategorizedItemComponent.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Category.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Category.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Category.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,249 @@
+package auction.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * The CaveatEmptor Category can have child categories and each has items.
+ * <p>
+ * Categories can be nested, this is expressed as a bidirectional one-to-many
+ * relationship that references parent and child categories.
+ * <p>
+ * Each Category can have many items (and an item can be in many categories). This
+ * is a many-to-many relationship. There are four strategies how you can map it.
+ * <p>
+ * First, the collection <tt>items</tt> is a true many-to-many association, with
+ * collections on both sides. There are no additional columns in the underlying
+ * many-to-many join table.
+ * <p>
+ * Second, the collection <tt>categorizedItems</tt> is a one-to-many association
+ * to an entity class <tt>CategorizedItem</tt> that represents the link. The
+ * <tt>Item</tt> class has the same collection mapped, to make it bidirectional.
+ * This intermediate class represents additional columns on the many-to-many
+ * join table, such as the user who added the item to the category, and the date
+ * of the addition.
+ * <p>
+ * Third, the collection <tt>categorizedItemComponents</tt> is a collection of
+ * value typed elements, of value type <tt>CategorizedItemComponent</tt>. This
+ * simplifies management of the link (no intermediate entity class) but allows
+ * only unidirectional navigation. The <tt>Item</tt> class does not know anything
+ * about this collection or the components - no shared references.
+ * <p>
+ * Finally, the map <tt>itemsAndUser</tt> represents the many-to-many association
+ * with a ternary relationship using a hash map. This map has item objects as keys,
+ * and user objects as values. The underlying many-to-many join table has three
+ * columns, <tt>CATEGORY_ID</tt>, <tt>ITEM_ID</tt>, and <tt>ADDED_BY_USER_ID</tt>.
+ * This strategy allows you to map an additional column (the user foreign key) of
+ * a many-to-many join table without writing an intermediate entity or component
+ * class.
+ *
+ * @see Item
+ * @see CategorizedItem
+ * @see CategorizedItemComponent
+ * @author Christian Bauer
+ */
+ at Entity
+ at Table(
+   name = "CATEGORY",
+   uniqueConstraints =
+    @UniqueConstraint(columnNames = {"CATEGORY_NAME", "PARENT_CATEGORY_ID"})
+    // If you want a constraint name in the schema, use <database-object> in XML instead
+)
+public class Category implements Serializable, Comparable {
+
+    @Id @GeneratedValue
+    @Column(name = "CATEGORY_ID")
+    private Long id = null;
+
+    @Version
+    @Column(name = "OBJ_VERSION")
+    private int version = 0;
+
+    @Column(name = "CATEGORY_NAME", length = 255, nullable = false)
+    private String name;
+
+    @OneToMany(mappedBy = "parentCategory", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
+    @org.hibernate.annotations.OrderBy(clause = "CATEGORY_NAME asc")
+    private List<Category> childCategories = new ArrayList<Category>(); // A bag with SQL ORDER BY
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "PARENT_CATEGORY_ID", nullable = true)
+    @org.hibernate.annotations.ForeignKey(name = "FK_CATEGORY_PARENT_ID")
+    private Category parentCategory;
+
+    @ManyToMany
+    @JoinTable(
+        name = "CATEGORY_ITEM",
+        joinColumns =        @JoinColumn(name = "CATEGORY_ID"),
+        inverseJoinColumns = @JoinColumn(name = "ITEM_ID")
+    )
+    @org.hibernate.annotations.IndexColumn(name = "DISPLAY_POSITION")
+    @org.hibernate.annotations.ForeignKey(
+        name        = "FK_CATEGORY_ITEM_CATEGORY_ID",
+        inverseName = "FK_CATEGORY_ITEM_ITEM_ID"
+    )
+    @org.hibernate.annotations.Filter(
+        name = "limitItemsByUserRank",
+        condition = ":currentUserRank >= (select u.RANK from USERS u where u.USER_ID = SELLER_ID)"
+    )
+    private List<Item> items = new ArrayList<Item>();
+
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
+    @org.hibernate.annotations.Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
+    @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
+    private Set<CategorizedItem> categorizedItems = new HashSet<CategorizedItem>();
+
+    @org.hibernate.annotations.CollectionOfElements
+    @JoinTable(
+        name = "CATEGORIZED_ITEM_COMPONENTS",
+        joinColumns = @JoinColumn(name = "CATEGORY_ID")
+    )
+    @org.hibernate.annotations.ForeignKey(name = "FK_CATEGORIZED_ITEM_COMPONENT_CATEGORY_ID")
+    private Set<CategorizedItemComponent> categorizedItemComponents = new HashSet<CategorizedItemComponent>();
+
+    @ManyToMany
+    @org.hibernate.annotations.MapKeyManyToMany(
+        joinColumns = @JoinColumn(name = "ITEM_ID")
+    )
+    @JoinTable(
+        name = "CATEGORY_ITEMS_BY_USER",
+        joinColumns = @JoinColumn(name = "CATEGORY_ID"),
+        inverseJoinColumns = @JoinColumn(name = "USER_ID")
+    )
+    @org.hibernate.annotations.ForeignKey(
+        name = "FK_CATEGORY_ITEMS_BY_USER_CATEGORY_ID",
+        inverseName = "FK_CATEGORY_ITEMS_BY_USER_USER_ID"
+        // TODO: Can't declare the foreign key constraint name for ITEM_ID...
+    )
+    private Map<Item,User> itemsAndUser = new HashMap<Item,User>();
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name="CREATED", nullable = false, updatable = false)
+    private Date created = new Date();
+
+    /**
+     * No-arg constructor for JavaBean tools
+     */
+    public Category() {}
+
+    /**
+     * Full constructor
+     */
+    public Category(String name,
+                    List<Category> childCategories,
+                    Category parentCategory,
+                    List<Item> items,
+                    Set<CategorizedItem> categorizedItems,
+                    Set<CategorizedItemComponent> categorizedItemComponents,
+                    Map<Item, User> itemsAndUser) {
+        this.name = name;
+        this.childCategories = childCategories;
+        this.parentCategory = parentCategory;
+        this.items = items;
+        this.categorizedItems = categorizedItems;
+        this.categorizedItemComponents = categorizedItemComponents;
+        this.itemsAndUser = itemsAndUser;
+    }
+
+    /**
+     * Simple constructors
+     */
+    public Category(String name) {
+        this.name = name;
+    }
+
+    public Category(String name, Category parentCategory) {
+        this.name = name;
+        this.parentCategory = parentCategory;
+    }
+
+    // ********************** Accessor Methods ********************** //
+
+    public Long getId() { return id; }
+    public int getVersion() { return version; }
+
+    public String getName() { return name; }
+    public void setName(String name) { this.name = name; }
+
+    public List getChildCategories() { return childCategories; }
+    public void addChildCategory(Category childCategory) {
+        if (childCategory == null) throw new IllegalArgumentException("Null child category!");
+        if (childCategory.getParentCategory() != null)
+            childCategory.getParentCategory().getChildCategories().remove(childCategory);
+        childCategory.setParentCategory(parentCategory);
+        childCategories.add(childCategory);
+    }
+    public void removeChildCategory(Category childCategory) {
+        if (childCategory == null) throw new IllegalArgumentException("Null child category!");
+        childCategory.setParentCategory(null);
+        childCategories.remove(childCategory);
+    }
+
+    public Category getParentCategory() { return parentCategory; }
+    private void setParentCategory(Category parentCategory) { this.parentCategory = parentCategory; }
+
+    // Regular many-to-many
+    public List<Item> getItems() { return items; }
+    public void addItem(Item item) {
+        if (item == null) throw new IllegalArgumentException("Null item!");
+        items.add(item);
+        item.getCategories().add(this);
+    }
+    public void removeItem(Item item) {
+        if (item == null) throw new IllegalArgumentException("Null item!");
+        items.remove(item);
+        item.getCategories().remove(this);
+    }
+
+    // Many-to-many with additional columns on join table, intermediate entity class
+    // To create a link, instantiate a CategorizedItem with the right constructor
+    // To remove a link, use getCategorizedItems().remove()
+    public Set<CategorizedItem> getCategorizedItems() { return categorizedItems; }
+
+    // Many-to-many with additional columns on join table, intermediate component class
+    public Set<CategorizedItemComponent> getCategorizedItemComponents() { return categorizedItemComponents; }
+
+    // Many-to-many with additional columns on join table, ternary hash map representation
+    public Map<Item, User> getItemsAndUser() { return itemsAndUser; }
+
+    public Date getCreated() { return created; }
+
+    // ********************** Common Methods ********************** //
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final Category category = (Category) o;
+
+        if (!created.equals(category.created)) return false;
+        if (!name.equals(category.name)) return false;
+        return !(parentCategory != null ?
+                !parentCategory.equals(category.parentCategory) :
+                category.parentCategory != null);
+
+    }
+
+    public int hashCode() {
+        int result;
+        result = name.hashCode();
+        result = 29 * result + (parentCategory != null ? parentCategory.hashCode() : 0);
+        result = 29 * result + created.hashCode();
+        return result;
+    }
+
+    public int compareTo(Object o) {
+        if (o instanceof Category) {
+            return this.getName().compareTo( ((Category)o).getName() );
+        }
+        return 0;
+    }
+
+    public String toString() {
+        return  "(" + getId() + ") Name: '" + getName();
+    }
+
+    // ********************** Business Methods ********************** //
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Category.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Comment.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Comment.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Comment.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,128 @@
+package auction.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * An immutable class representing a comment from users.
+ * <p>
+ * Comments are always made in the context of an auction, that
+ * is, a comment has a reference to an Item. The comment has
+ * a free text field and a rating (using a typesafe enumeration).
+ *
+ * @see Item
+ * @see User
+ * @see Rating
+ * @author Christian Bauer
+ */
+ at Entity
+ at Table(name = "COMMENT")
+public class Comment implements Serializable, Comparable {
+
+    @Id @GeneratedValue
+    @Column(name = "COMMENT_ID")
+    private Long id = null;
+
+    @Version
+    @Column(name = "OBJ_VERSION")
+    private int version = 0;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "RATING", nullable = false, updatable = false)
+	private Rating rating;
+
+    @Column(name = "COMMENT_TEXT", length = 4000, nullable = true)
+	private String text;
+
+    @ManyToOne(fetch = FetchType.EAGER)
+    @JoinColumn(name = "FROM_USER_ID", nullable = false, updatable = false)
+    @org.hibernate.annotations.ForeignKey(name = "FK_FROM_USER_ID")
+    private User fromUser;
+
+    @ManyToOne(fetch = FetchType.EAGER)
+    @JoinColumn(name = "ABOUT_ITEM_ID", nullable = false, updatable = false)
+    @org.hibernate.annotations.ForeignKey(name = "FK_ABOUT_ITEM_ID")
+	private Item item;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name="CREATED", nullable = false, updatable = false)
+	private Date created = new Date();
+
+	/**
+	 * No-arg constructor for JavaBean tools
+	 */
+	public Comment() {}
+
+	/**
+	 * Full constructor
+	 *
+	 * @param rating
+	 * @param text
+	 * @param fromUser
+	 * @param item
+	 */
+	public Comment(Rating rating, String text, User fromUser, Item item) {
+		this.rating = rating;
+		this.text = text;
+		this.fromUser = fromUser;
+		this.item = item;
+	}
+
+	// ********************** Accessor Methods ********************** //
+
+	public Long getId() { return id; }
+    public int getVersion() { return version; }
+
+	public Rating getRating() { return rating; }
+
+	public String getText() { return text; }
+	public void setText(String text) { this.text = text; }
+
+	public User getFromUser() { return fromUser; }
+
+	public Item getItem() { return item; }
+
+	public Date getCreated() { return created; }
+
+	// ********************** Common Methods ********************** //
+
+	public boolean equals(Object o) {
+		if (this == o) return true;
+		if (!(o instanceof Comment)) return false;
+
+		final Comment comment = (Comment) o;
+
+        if (! (created.getTime() == comment.created.getTime()) ) return false;
+		if (!rating.equals(comment.rating)) return false;
+		if (text != null ? !text.equals(comment.text) : comment.text != null) return false;
+
+		return true;
+	}
+
+	public int hashCode() {
+		int result;
+		result = rating.hashCode();
+		result = 29 * result + (text != null ? text.hashCode() : 0);
+		result = 29 * result + created.hashCode();
+		return result;
+	}
+
+	public String toString() {
+		return "Comment ('" + getId() + "'), " +
+				"Rating: '" + getRating() + "'";
+	}
+
+	public int compareTo(Object o) {
+		if (o instanceof Comment) {
+            // Don't compare Date objects! Use the time in milliseconds!
+            return Long.valueOf(this.getCreated().getTime()).compareTo(
+                    Long.valueOf( ((Comment)o).getCreated().getTime())
+                   );
+		}
+		return 0;
+	}
+
+	// ********************** Business Methods ********************** //
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Comment.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCard.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCard.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCard.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,83 @@
+package auction.model;
+
+import javax.persistence.*;
+
+/**
+ * This billing strategy can handle various credit cards.
+ * <p>
+ * The type of credit card is handled with a typesafe
+ * enumeration, <tt>CreditCardType</tt>.
+ *
+ * @see CreditCardType
+ * @author Christian Bauer
+ */
+ at Entity
+ at DiscriminatorValue("CC")
+ at SecondaryTable(
+    name = "CREDIT_CARD",
+    pkJoinColumns = @PrimaryKeyJoinColumn(name = "CREDIT_CARD_ID")
+)
+// TODO: Can't name foreign key constraint for PK join columns
+public class CreditCard extends BillingDetails {
+
+    @Enumerated(EnumType.STRING)
+    @Column(table = "CREDIT_CARD", name = "CC_TYPE", nullable = false)
+    private CreditCardType type;
+
+    @Column(table = "CREDIT_CARD", name = "CC_NUMBER", nullable = false, updatable = false, length = 16)
+    private String number;
+
+    @Column(table = "CREDIT_CARD", name = "CC_EXP_MONTH", nullable = false, updatable = false, length = 2)
+    private String expMonth;
+
+    @Column(table = "CREDIT_CARD", name = "CC_EXP_YEAR", nullable = false, updatable = false, length = 4)
+    private String expYear;
+
+    /**
+     * No-arg constructor for JavaBean tools
+     */
+    public CreditCard() { super(); }
+
+    /**
+     * Full constructor.
+     *
+     * @param owner
+     * @param user
+     * @param type
+     * @param expMonth
+     * @param expYear
+     */
+    public CreditCard(String owner, User user, String number, CreditCardType type,
+                      String expMonth, String expYear) {
+        super(owner, user);
+        this.type = type;
+        this.number = number;
+        this.expMonth = expMonth;
+        this.expYear = expYear;
+    }
+
+    // ********************** Accessor Methods ********************** //
+
+    public CreditCardType getType() { return type; }
+
+    public String getNumber() { return number; }
+
+    public String getExpMonth() { return expMonth; }
+
+    public String getExpYear() { return expYear; }
+
+    // ********************** Common Methods ********************** //
+
+    public String toString() {
+        return  "CreditCard ('" + getId() + "'), " +
+                "Type: '" + getType() + "'";
+    }
+
+    // ********************** Business Methods ********************** //
+
+    public boolean isValid() {
+        // Use the type to validate the CreditCard details.
+        return getType().isValid(this);
+    }
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCard.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCardType.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCardType.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCardType.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,31 @@
+package auction.model;
+
+/**
+ * A simple enumeration.
+ *
+ * @author Christian Bauer
+ */
+public enum CreditCardType {
+
+	MASTERCARD("Mastercard"),
+    VISA("Visa"),
+    AMEX("American Express");
+
+    private final String debugName;
+
+	private CreditCardType(String debugName) {
+		this.debugName = debugName;
+	}
+
+	public String toString() {
+	    return debugName;
+	}
+
+	// ********************** Business Methods ********************** //
+
+	public boolean isValid(CreditCard cc) {
+		// TODO: Implement syntactical validation of credit card information.
+		return true;
+	}
+
+}
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/CreditCardType.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Item.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Item.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Item.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,408 @@
+package auction.model;
+
+import auction.exceptions.*;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * An item for auction.
+ *
+ * @author Christian Bauer
+ */
+ at NamedQueries({
+    @NamedQuery(
+        name = "Item-getMinBid",
+        query = "select b from Bid b where b.amount.value = (select min(b.amount.value) from Bid b where b.item.id = :itemid)"
+    ),
+    @NamedQuery(
+        name = "Item-getMaxBid",
+        query = "select b from Bid b where b.amount.value = (select max(b.amount.value) from Bid b where b.item.id = :itemid)"
+    ),
+    @NamedQuery(
+     name = "findItemsByDescription",
+     query = "select i from Item i where i.description like :desc)",
+     hints = {
+      @QueryHint(name = "org.hibernate.comment", value = "My Comment"),
+      @QueryHint(name = "org.hibernate.fetchSize", value = "50"),
+      @QueryHint(name = "org.hibernate.flushMode", value = "never"),
+      @QueryHint(name = "org.hibernate.readOnly", value = "true"),
+      @QueryHint(name = "org.hibernate.timeout", value = "60")
+     })
+})
+/*
+ at NamedNativeQueries({
+    @NamedNativeQuery(
+     name = "findItemsByDescriptionWithSQL",
+     query = "select i.NAME, i.PRICE ... from ITEM i where i.DESC = :desc",
+     resultClass = auction.model.Item.class
+    )
+})
+*/
+
+ at Entity
+ at Table(name = "ITEM")
+ at org.hibernate.annotations.Filter(
+    name = "limitItemsByUserRank",
+    condition=":currentUserRank >= " +
+              "(select u.RANK from USER u" +
+              " where u.USER_ID = SELLER_ID)"
+)
+ at org.hibernate.annotations.Check(
+    constraints = "START_DATE < END_DATE"
+)
+ at org.hibernate.annotations.Table(
+    appliesTo = "ITEM",
+    indexes =
+      @org.hibernate.annotations.Index(
+        name = "IDX_INITIAL_PRICE",
+        columnNames = { "INITIAL_PRICE", "INITIAL_PRICE_CURRENCY" }
+      )
+)
+public class Item implements Serializable, Comparable, Auditable {
+
+    private static final String COLLECTION_ID_GENERATOR = "identity";
+
+    @Id @GeneratedValue
+    @Column(name = "ITEM_ID")
+    private Long id = null;
+
+    @Version
+    @Column(name = "OBJ_VERSION")
+    private int version = 0;
+
+    @Column(name = "ITEM_NAME", length = 255, nullable = false, updatable = false)
+    private String name;
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name="SELLER_ID", nullable = false, updatable = false)
+    @org.hibernate.annotations.ForeignKey(name = "FK_SELLER_ID")
+    private User seller;
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinTable(
+        name = "ITEM_BUYER",
+        joinColumns = @JoinColumn(name = "ITEM_ID"),
+        inverseJoinColumns = @JoinColumn(name = "USER_ID")
+    )
+    // TODO: Foreign key name for ITEM_ID is ignored
+    @org.hibernate.annotations.ForeignKey(
+        name = "FK_ITEM_BUYER_USER_ID",
+        inverseName = "FK_ITEM_BUYER_ITEM_ID"
+    )
+    private User buyer;
+
+    @Column(name = "DESCRIPTION", length = 4000, nullable = false)
+    private String description;
+
+    @org.hibernate.annotations.Type(type = "monetary_amount_usd")
+    @org.hibernate.annotations.Columns(columns = {
+        @Column( name="INITIAL_PRICE", nullable = false, length = 2),
+        @Column( name="INITIAL_PRICE_CURRENCY", nullable = false, length = 3)
+    })
+    private MonetaryAmount initialPrice;
+
+    @org.hibernate.annotations.Type(type = "monetary_amount_usd")
+    @org.hibernate.annotations.Columns(columns = {
+        @Column( name="RESERVE_PRICE", nullable = false, length = 2),
+        @Column( name="RESERVE_PRICE_CURRENCY", nullable = false, length = 3)
+    })
+    private MonetaryAmount reservePrice;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "START_DATE", nullable = false, updatable = false)
+    private Date startDate;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "END_DATE", nullable = false, updatable = false)
+    @org.hibernate.annotations.Index(name = "IDX_END_DATE")
+    private Date endDate;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "ITEM_STATE", nullable = false)
+    private ItemState state;
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "APPROVED_BY_USER_ID", nullable = true)
+    @org.hibernate.annotations.ForeignKey(name = "FK_APPROVED_BY_USER_ID")
+    private User approvedBy;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "APPROVAL_DATETIME", nullable = true)
+    private Date approvalDatetime;
+
+    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+    @JoinColumn(name = "ITEM_ID", nullable = false)
+    @org.hibernate.annotations.IndexColumn(name = "BID_POSITION")
+    @org.hibernate.annotations.BatchSize(size = 10)
+    private List<Bid> bids = new ArrayList<Bid>();
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "SUCCESSFUL_BID_ID", nullable = true)
+    @org.hibernate.annotations.ForeignKey(name = "FK_SUCCESSFUL_BID_ID")
+    private Bid successfulBid;
+
+    @MapKey(name="id")
+    @OneToMany(mappedBy = "item")
+    private Map<Long,Bid> bidsByIdentifier = new HashMap<Long,Bid>(); // Not very useful
+
+    @ManyToMany(mappedBy = "items")
+    private Set<Category> categories = new HashSet<Category>();
+
+    @OneToMany(cascade = CascadeType.ALL, mappedBy = "item")
+    @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
+    private Set<CategorizedItem> categorizedItems = new HashSet<CategorizedItem>();
+
+    @org.hibernate.annotations.CollectionOfElements
+    @org.hibernate.annotations.CollectionId(
+        columns = @Column(name = "ITEM_IMAGE_ID"),
+        type = @org.hibernate.annotations.Type(type = "long"),
+        generator = COLLECTION_ID_GENERATOR
+    )
+    @JoinTable(
+        name = "ITEM_IMAGES",
+        joinColumns = @JoinColumn(name = "ITEM_ID")
+    )
+    @Column(name = "FILENAME")
+    @org.hibernate.annotations.ForeignKey(name = "FK_ITEM_IMAGE_ITEM_ID")
+    private Collection<String> images = new ArrayList<String>();
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name="CREATED", nullable = false, updatable = false)
+    private Date created = new Date();
+
+    /**
+     * No-arg constructor for JavaBean tools.
+     */
+    public Item() {}
+
+    /**
+     * Full constructor
+     */
+    public Item(String name, User seller, User buyer, String description,
+                MonetaryAmount initialPrice, MonetaryAmount reservePrice, Date startDate, Date endDate,
+                ItemState state, User approvedBy, Date approvalDatetime,
+                List<Bid> bids, Bid successfulBid, Map<Long, Bid> bidsByIdentifier,
+                Set<Category> categories, Set<CategorizedItem> categorizedItems,
+                Collection<String> images) {
+        this.name = name;
+        this.seller = seller;
+        this.buyer = buyer;
+        this.description = description;
+        this.initialPrice = initialPrice;
+        this.reservePrice = reservePrice;
+        this.startDate = startDate;
+        this.endDate = endDate;
+        this.state = state;
+        this.approvedBy = approvedBy;
+        this.approvalDatetime = approvalDatetime;
+        this.bids = bids;
+        this.successfulBid = successfulBid;
+        this.bidsByIdentifier = bidsByIdentifier;
+        this.categories = categories;
+        this.categorizedItems = categorizedItems;
+        this.images = images;
+
+        // Referential integrity
+        seller.getItemsForSale().add(this);
+    }
+
+    /**
+     * Simple constructors
+     */
+    public Item(String name, String description, User seller,
+                MonetaryAmount initialPrice, MonetaryAmount reservePrice,
+                Date startDate, Date endDate) {
+        this.name = name;
+        this.seller = seller;
+        this.description = description;
+        this.initialPrice = initialPrice;
+        this.reservePrice = reservePrice;
+        this.startDate = startDate;
+        this.endDate = endDate;
+        this.state = ItemState.DRAFT;
+
+        // Referential integrity
+        seller.getItemsForSale().add(this);
+    }
+
+    // ********************** Accessor Methods ********************** //
+
+    public Long getId() { return id; }
+    public int getVersion() { return version; }
+
+    public String getName() { return name; }
+
+    public User getSeller() { return seller; }
+
+    public User getBuyer() { return buyer; }
+    public void setBuyer(User buyer) { this.buyer = buyer; }
+
+    public String getDescription() { return description; }
+    public void setDescription(String description) { this.description = description; }
+
+    public MonetaryAmount getInitialPrice() { return initialPrice; }
+
+    public MonetaryAmount getReservePrice() { return reservePrice; }
+
+    public Date getStartDate() { return startDate; }
+
+    public Date getEndDate() { return endDate; }
+
+    public ItemState getState() { return state; }
+
+    public User getApprovedBy() { return approvedBy; }
+    public void setApprovedBy(User approvedBy) { this.approvedBy = approvedBy; }
+
+    public Date getApprovalDatetime() { return approvalDatetime; }
+    public void setApprovalDatetime(Date approvalDatetime) { this.approvalDatetime = approvalDatetime; }
+
+    public List<Bid> getBids() { return bids; }
+    public void addBid(Bid bid) {
+        if (bid == null)
+            throw new IllegalArgumentException("Can't add a null Bid.");
+        this.getBids().add(bid);
+        // Don't have to set the "other" side, a Bid can only be instantiated with a given item
+    }
+
+    public Bid getSuccessfulBid() { return successfulBid; }
+    public void setSuccessfulBid(Bid successfulBid) {
+        // Has to preserve the integrity by using a procedure and loop, bad Java...
+        if (successfulBid != null) {
+            for (Bid bid : getBids())
+                bid.setSuccessful(false);
+            successfulBid.setSuccessful(true);
+            this.successfulBid = successfulBid;
+        }
+    }
+
+    public Map<Long, Bid> getBidsByIdentifier() { return bidsByIdentifier; }
+    public void setBidsByIdentifier(Map<Long, Bid> bidsByIdentifier) { this.bidsByIdentifier = bidsByIdentifier; }
+
+    // Read-only, modify through Category#addItem() and Category at removeItem();
+    public Set<Category> getCategories() { return Collections.unmodifiableSet(categories); }
+
+    // Read-only, to create a link, instantiate a CategorizedItem with the right constructor
+    // To remove a link, use Category.getCategorizedItems().remove()
+    public Set<CategorizedItem> getCategorizedItems() { return categorizedItems; }
+
+    public Collection<String> getImages() { return images; }
+
+    public Date getCreated() { return created; }
+
+    // ********************** Common Methods ********************** //
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof Item)) return false;
+
+        final Item item = (Item) o;
+
+        if (! (created.getTime() == item.created.getTime()) ) return false;
+        if (name != null ? !name.equals(item.name) : item.name != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (name != null ? name.hashCode() : 0);
+        result = 29 * result + created.hashCode();
+        return result;
+    }
+
+    public String toString() {
+        return  "Item ('" + getId() + "'), " +
+                "Name: '" + getName() + "' " +
+                "Initial Price: '" + getInitialPrice()+ "'";
+    }
+
+    public int compareTo(Object o) {
+        if (o instanceof Item) {
+            // Don't compare Date objects! Use the time in milliseconds!
+            return Long.valueOf(this.getCreated().getTime()).compareTo(
+                    Long.valueOf( ((Item)o).getCreated().getTime())
+                   );
+        }
+        return 0;
+    }
+
+    // ********************** Business Methods ********************** //
+
+    /**
+     * Places a bid while checking business constraints.
+     *
+     * This method may throw a BusinessException if one of the requirements
+     * for the bid placement wasn't met, e.g. if the auction already ended.
+     *
+     * @param bidder
+     * @param bidAmount
+     * @param currentMaxBid  the most valuable bid for this item
+     * @param currentMinBid  the least valuable bid for this item
+     * @return
+     * @throws BusinessException
+     */
+    public Bid placeBid(User bidder, MonetaryAmount bidAmount,
+                        Bid currentMaxBid, Bid currentMinBid)
+        throws BusinessException {
+
+        // Check initial price
+        if (initialPrice.compareTo(bidAmount) > 0) {
+            throw new BusinessException("Bid lower than initial price");
+        }
+
+        // Check reserve price
+        if (reservePrice.compareTo(bidAmount) > 0) {
+            throw new BusinessException("Bid lower than reserve price");
+        }
+
+        // Check highest bid (can also be a different Strategy (pattern))
+        if (currentMaxBid != null && currentMaxBid.getAmount().compareTo(bidAmount) > 0) {
+            throw new BusinessException("Bid too low");
+        }
+
+        // Auction is active
+        if ( !this.getState().equals(ItemState.ACTIVE) )
+            throw new BusinessException("Auction is not active yet");
+
+        // Auction still valid
+        if ( this.getEndDate().before( new Date() ) )
+            throw new BusinessException("Can't place new bid, auction already ended");
+
+        // Create new Bid
+        Bid newBid = new Bid(bidAmount, this, bidder);
+
+        // Place bid for this Item
+        this.addBid(newBid);
+
+        return newBid;
+    }
+
+    /**
+     * Anyone can set this item into PENDING state for approval.
+     */
+    public void setPendingForApproval() {
+        state = ItemState.PENDING;
+    }
+
+    /**
+     * Approve this item for auction and set its state to active.
+     *
+     * @param byUser
+     * @throws BusinessException
+     */
+    public void approve(User byUser) throws BusinessException {
+
+        if ( !byUser.isAdmin() )
+            throw new PermissionException("Not an administrator");
+
+        if ( !state.equals(ItemState.PENDING) )
+            throw new IllegalStateException("Item still in draft");
+
+        state = ItemState.ACTIVE;
+        approvedBy = byUser;
+        approvalDatetime = new Date();
+    }
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Item.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ItemState.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ItemState.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ItemState.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,25 @@
+package auction.model;
+
+/**
+ * A simple enumeration.
+ *
+ * @author Christian Bauer
+ */
+public enum ItemState {
+
+    DRAFT('D'), PENDING('P'), ACTIVE('A');
+
+    private final char state;
+
+	private ItemState(char state) {
+		this.state = state;
+	}
+
+    public char value() {
+        return state;
+    }
+
+	public String toString() {
+		return Character.toString(state);
+	}
+}
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ItemState.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/MonetaryAmount.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/MonetaryAmount.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/MonetaryAmount.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,79 @@
+package auction.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Currency;
+
+/**
+ * Represents a monetary amount as value and currency.
+ * <p>
+ * Has some illustrative and non-funtional money conversion magic.
+ * @author Gavin King
+ * @author Christian Bauer
+ */
+public class MonetaryAmount implements Serializable {
+
+	private final BigDecimal value;
+	private final Currency currency;
+
+	public MonetaryAmount(BigDecimal value, Currency currency) {
+		this.value = value;
+		this.currency = currency;
+	}
+
+	public Currency getCurrency() {
+		return currency;
+	}
+
+	public BigDecimal getValue() {
+		return value;
+	}
+
+	// ********************** Common Methods ********************** //
+
+	public boolean equals(Object o) {
+		if (this == o) return true;
+		if (!(o instanceof MonetaryAmount)) return false;
+
+		final MonetaryAmount monetaryAmount = (MonetaryAmount) o;
+
+		if (!currency.equals(monetaryAmount.currency)) return false;
+		if (!value.equals(monetaryAmount.value)) return false;
+
+		return true;
+	}
+
+	public int hashCode() {
+		int result;
+		result = value.hashCode();
+		result = 29 * result + currency.hashCode();
+		return result;
+	}
+
+	public String toString() {
+		return "Value: '" + getValue() + "', " +
+		        "Currency: '" + getCurrency() + "'";
+	}
+
+	public int compareTo(Object o) {
+		if (o instanceof MonetaryAmount) {
+            // TODO: This requires some conversion magic and is therefore not implemented
+			return this.getValue().compareTo(((MonetaryAmount) o).getValue());
+		}
+		return 0;
+	}
+
+	// ********************** Business Methods ********************** //
+
+	public static MonetaryAmount fromString(String amount, String currencyCode) {
+		return new MonetaryAmount(new BigDecimal(amount),
+								  Currency.getInstance(currencyCode));
+	}
+
+	public static MonetaryAmount convert(MonetaryAmount amount,
+										 Currency toConcurrency) {
+		// TODO: This requires some conversion magic and is therefore not implemented
+		return new MonetaryAmount(amount.getValue(), toConcurrency);
+	}
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/MonetaryAmount.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Rating.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Rating.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Rating.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,5 @@
+package auction.model;
+
+public enum Rating {
+	EXCELLENT, OK, BAD;
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Rating.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Shipment.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Shipment.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Shipment.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,145 @@
+package auction.model;
+
+import javax.persistence.*;
+import java.util.Date;
+
+/**
+ * Escrow base class for CaveatEmptor.
+ *
+ * A particular shipment under supervision, from a seller to a buyer.
+ * <p>
+ * The process (see <tt>ShipmentState</tt>) is supposed to be:
+ * <li>AGREED: Both parties agree on the deal and a Shipment is created
+ * <li>PAYED: The buyer payed the shipment
+ * <li>IN_TRANSIT: The seller sent the shipment
+ * <li>ACCEPTED: The buyer accepted the shipment in the inspection period
+ * <li>COMPLETE: The payment has been transfered to the seller
+ * <p>
+ * The escrow service may be in the context of an auction, or utilized
+ * by all users for deals made outside of CaveatEmptor. Hence, the
+ * auction <tt>Item</tt> reference is optional and may be null.
+ *
+ * @author Christian Bauer
+ */
+ at Entity
+ at Table(name = "SHIPMENT")
+ at SecondaryTable(
+    name = "ITEM_SHIPMENT",
+    pkJoinColumns = @PrimaryKeyJoinColumn(name = "SHIPMENT_ID")
+)
+// TODO: Can't declare foreign key constraint name for PK join column
+public class Shipment {
+
+    @Id @GeneratedValue
+    @Column(name = "SHIPMENT_ID")
+    private Long id = null;
+
+    @Version
+    @Column(name = "OBJ_VERSION")
+    private int version = 0;
+
+    @ManyToOne(fetch = FetchType.EAGER)
+    @JoinColumn(name="DELIVERY_ADDRESS_ID", nullable = false, updatable = false)
+    @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.JOIN)
+    @org.hibernate.annotations.ForeignKey(name = "FK_SHIPMENT_DELIVERY_ADDRESS_ID")
+    private AddressEntity deliveryAddress;
+
+    @ManyToOne
+    @JoinColumn(table = "ITEM_SHIPMENT", name = "ITEM_ID")
+    @org.hibernate.annotations.ForeignKey(
+        name = "FK_ITEM_SHIPMENT_ITEM_ID",
+        inverseName = "FK_ITEM_SHIPMENT_SHIPMENT_ID"
+    )
+    private Item auction; // Nullable
+
+    @ManyToOne(fetch = FetchType.EAGER)
+    @JoinColumn(name="BUYER_ID", nullable = false, updatable = false)
+    @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.JOIN)
+    @org.hibernate.annotations.ForeignKey(name = "FK_SHIPMENT_BUYER_ID")
+    private User buyer;
+
+    @ManyToOne(fetch = FetchType.EAGER)
+    @JoinColumn(name="SELLER_ID", nullable = false, updatable = false)
+    @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.JOIN)
+    @org.hibernate.annotations.ForeignKey(name = "FK_SHIPMENT_SELLER_ID")
+    private User seller;
+
+    @Column(name="INSPECTION_PERIOD_DAYS", nullable = false, updatable = false)
+    private int inspectionPeriodDays;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "SHIPMENT_STATE", nullable = false)
+    private ShipmentState state = ShipmentState.AGREED;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name="CREATED", nullable = false, updatable = false)
+    private Date created = new Date();
+
+    /**
+     * No-arg constructor for JavaBean tools
+     */
+    public Shipment() {}
+
+    /**
+     * Regular constructor
+     */
+    public Shipment(AddressEntity deliveryAddress, User buyer, User seller, int inspectionPeriodDays) {
+        this.deliveryAddress = deliveryAddress;
+        this.buyer = buyer;
+        this.seller = seller;
+        this.inspectionPeriodDays = inspectionPeriodDays;
+    }
+
+    // ********************** Accessor Methods ********************** //
+
+    public Long getId() { return id; }
+    public int getVersion() { return version; }
+
+    public AddressEntity getDeliveryAddress() { return deliveryAddress; }
+
+    public Item getAuction() { return auction; }
+    public void setAuction(Item auction) { this.auction = auction; }
+
+    public User getSeller() { return seller; }
+
+    public User getBuyer() { return buyer; }
+
+    public int getInspectionPeriodDays() { return inspectionPeriodDays; }
+
+    public ShipmentState getState() { return state; }
+    public void setState(ShipmentState state) { this.state = state; }
+
+    public Date getCreated() { return created; }
+
+    // ********************** Common Methods ********************** //
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof Shipment)) return false;
+
+        final Shipment shipment = (Shipment) o;
+
+        if (inspectionPeriodDays != shipment.inspectionPeriodDays) return false;
+        if (!buyer.getId().equals(shipment.buyer.getId())) return false;
+        if (!created.equals(shipment.created)) return false;
+        return seller.getId().equals(shipment.seller.getId());
+
+    }
+
+    public int hashCode() {
+        int result;
+        result = seller.getId().hashCode();
+        result = 29 * result + buyer.getId().hashCode();
+        result = 29 * result + inspectionPeriodDays;
+        result = 29 * result + created.hashCode();
+        return result;
+    }
+
+    public String toString() {
+        return  "Shipment ('" + getId() + "'), " +
+                "State: '" + getState() + "'";
+    }
+
+    // ********************** Business Methods ********************** //
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/Shipment.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ShipmentState.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ShipmentState.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ShipmentState.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,12 @@
+package auction.model;
+
+/**
+ * A simple enumeration, for the escrow service.
+ *
+ * @author Christian Bauer
+ */
+public enum ShipmentState {
+
+    AGREED, PAYED, IN_TRANSIT, ACCEPTED, COMPLETE
+
+}
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/ShipmentState.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/User.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/User.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/User.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,273 @@
+package auction.model;
+
+import auction.exceptions.BusinessException;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * A user of the CaveatEmptor auction application.
+ *
+ * @author Christian Bauer
+ */
+ at Entity
+ at Table(name = "USERS")
+ at SecondaryTable(
+    name = "BILLING_ADDRESS",
+    pkJoinColumns = {
+        @PrimaryKeyJoinColumn(name="USER_ID")
+    }
+)
+ at org.hibernate.annotations.BatchSize(size = 10)
+public class User implements Serializable, Comparable {
+
+    @Id @GeneratedValue
+    @Column(name = "USER_ID")
+    private Long id = null;
+
+    @Version
+    @Column(name = "OBJ_VERSION")
+    private int version = 0;
+
+    @Column(name = "FIRSTNAME", length = 255, nullable = false)
+    private String firstname;
+
+    @Column(name = "LASTNAME", length = 255, nullable = false)
+    private String lastname;
+
+    @Column(name = "USERNAME", length = 16, nullable = false, unique = true)
+    //@org.hibernate.annotations.Check( constraints = "regexp_like(USERNAME,'^[[:alpha:]]+$')" )
+    private String username; // Unique and immutable
+
+    @Column(name = "`PASSWORD`", length = 12, nullable = false)
+    private String password;
+
+    @Column(name = "EMAIL", length = 255, nullable = false)
+    private String email;
+
+    @Column(name = "RANK", nullable = false)
+    private int ranking = 0;
+
+    @Column(name = "IS_ADMIN", nullable = false)
+    private boolean admin = false;
+
+    @Embedded
+    @AttributeOverrides( {
+        @AttributeOverride(name   = "street",
+                           column = @Column(name="HOME_STREET", length = 255) ),
+        @AttributeOverride(name   = "zipcode",
+                           column = @Column(name="HOME_ZIPCODE", length = 16) ),
+        @AttributeOverride(name   = "city",
+                           column = @Column(name="HOME_CITY", length = 255) )
+        })
+    private Address homeAddress;
+
+    @Embedded
+    @AttributeOverrides( {
+        @AttributeOverride(
+            name   = "street",
+            column = @Column(name="STREET", length = 255,
+                             table = "BILLING_ADDRESS")
+        ),
+        @AttributeOverride(
+            name   = "zipcode",
+            column = @Column(name="ZIPCODE", length = 16,
+                             table = "BILLING_ADDRESS")
+        ),
+        @AttributeOverride(
+            name   = "city",
+            column = @Column(name="CITY", length = 255,
+                             table = "BILLING_ADDRESS")
+        )
+    })
+    // TODO: This is ignored: @org.hibernate.annotations.ForeignKey(name = "FK_BILLING_ADDRESS_ID")
+    private Address billingAddress;
+
+    @OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
+    @PrimaryKeyJoinColumn
+    private AddressEntity shippingAddress;
+
+    @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, mappedBy = "user")
+    @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
+    private Set<BillingDetails> billingDetails = new HashSet<BillingDetails>();
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name="DEFAULT_BILLING_DETAILS_ID", nullable = true)
+    @org.hibernate.annotations.ForeignKey(name = "FK_DEFAULT_BILLING_DETAILS_ID")
+    private BillingDetails defaultBillingDetails;
+
+    @OneToMany(mappedBy = "seller")
+    private Collection<Item> itemsForSale = new ArrayList<Item>();
+
+    @OneToMany(mappedBy = "buyer")
+    private Set<Item> boughtItems = new HashSet<Item>();
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name="CREATED", nullable = false, updatable = false)
+    private Date created = new Date();
+
+    /**
+     * No-arg constructor for JavaBean tools
+     */
+    public User() {}
+
+    /**
+     * Full constructor
+     */
+    public User(String firstname, String lastname, String username, String password, String email, int ranking,
+                boolean admin, Address homeAddress, Address billingAddress, AddressEntity shippingAddress,
+                Set<BillingDetails> billingDetails, BillingDetails defaultBillingDetails,
+                Set<Item> itemsForSale, Set<Item> boughtItems) {
+        this.firstname = firstname;
+        this.lastname = lastname;
+        this.username = username;
+        this.password = password;
+        this.email = email;
+        this.ranking = ranking;
+        this.admin = admin;
+        this.homeAddress = homeAddress;
+        this.billingAddress = billingAddress;
+        this.shippingAddress = shippingAddress;
+        this.billingDetails = billingDetails;
+        this.defaultBillingDetails = defaultBillingDetails;
+        this.itemsForSale = itemsForSale;
+        this.boughtItems = boughtItems;
+    }
+
+    /**
+     * Simple constructor.
+     */
+    public User(String firstname, String lastname,
+                String username, String password, String email) {
+        this.firstname = firstname;
+        this.lastname = lastname;
+        this.username = username;
+        this.password = password;
+        this.email = email;
+    }
+
+    // ********************** Accessor Methods ********************** //
+
+    public Long getId() { return id; }
+    public int getVersion() { return version; }
+
+    public String getFirstname() { return firstname; }
+    public void setFirstname(String firstname) { this.firstname = firstname; }
+
+    public String getLastname() { return lastname; }
+    public void setLastname(String lastname) { this.lastname = lastname; }
+
+    public String getUsername() { return username; }
+
+    public String getPassword() { return password; }
+    public void setPassword(String password) { this.password = password; }
+
+    public String getEmail() { return email; }
+    public void setEmail(String email) { this.email = email; }
+
+    public int getRanking() { return ranking; }
+    public void setRanking(int ranking) { this.ranking = ranking; }
+
+    public boolean isAdmin() { return admin; }
+    public void setAdmin(boolean admin) { this.admin = admin; }
+
+    public Address getHomeAddress() { return homeAddress; }
+    public void setHomeAddress(Address homeAddress) { this.homeAddress = homeAddress; }
+
+    public Address getBillingAddress() { return billingAddress; }
+    public void setBillingAddress(Address billingAddress) { this.billingAddress = billingAddress; }
+
+    public AddressEntity getShippingAddress() { return shippingAddress; }
+    public void setShippingAddress(AddressEntity shippingAddress) { this.shippingAddress = shippingAddress; }
+
+    public Set getBillingDetails() { return billingDetails; }
+    /**
+      * Adds a <tt>BillingDetails</tt> to the set.
+      * <p>
+      * This method checks if there is only one billing method
+      * in the set, then makes this the default.
+      *
+      * @param billingDetails
+      */
+     public void addBillingDetails(BillingDetails billingDetails) {
+         if (billingDetails == null)
+             throw new IllegalArgumentException("Can't add a null BillingDetails.");
+         this.getBillingDetails().add(billingDetails);
+
+         if (getBillingDetails().size() == 1) {
+             setDefaultBillingDetails(billingDetails);
+         }
+    }
+    /**
+     * Removes a <tt>BillingDetails</tt> from the set.
+     * <p>
+     * This method checks if the removed is the default element,
+     * and will throw a BusinessException if there is more than one
+     * left to chose from. This might actually not be the best way
+     * to handle this situation.
+     *
+     * @param billingDetails
+     * @throws BusinessException
+     */
+    public void removeBillingDetails(BillingDetails billingDetails)
+        throws BusinessException {
+        if (billingDetails == null)
+            throw new IllegalArgumentException("Can't add a null BillingDetails.");
+
+        if (getBillingDetails().size() >= 2) {
+            getBillingDetails().remove(billingDetails);
+            setDefaultBillingDetails((BillingDetails)getBillingDetails().iterator().next());
+        } else {
+            throw new BusinessException("Please set new default BillingDetails first");
+        }
+    }
+
+    public BillingDetails getDefaultBillingDetails() { return defaultBillingDetails; }
+    public void setDefaultBillingDetails(BillingDetails defaultBillingDetails) {
+        this.defaultBillingDetails = defaultBillingDetails;
+    }
+
+    public Collection<Item> getItemsForSale() { return itemsForSale; }
+    public void setItemsForSale(Collection<Item> itemsForSale) { this.itemsForSale = itemsForSale; }
+
+    public Set<Item> getBoughtItems() { return boughtItems; }
+    public void addBoughtItem(Item item) {
+        if (item == null) throw new IllegalArgumentException("Null Item!");
+        item.setBuyer(this);
+        boughtItems.add(item);
+    }
+
+    public Date getCreated() { return created; }
+
+    // ********************** Common Methods ********************** //
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof User)) return false;
+        final User user = (User) o;
+        return getUsername().equals(user.getUsername());
+    }
+
+    public int hashCode() {
+        return getUsername().hashCode();
+    }
+
+    public String toString() {
+        return  "User ('" + getId() + "'), " +
+                "Username: '" + getUsername() + "'";
+    }
+
+    public int compareTo(Object o) {
+        if (o instanceof User)
+            // Don't compare Date objects! Use the time in milliseconds!
+            return Long.valueOf(this.getCreated().getTime()).compareTo(
+                    Long.valueOf( ((User)o).getCreated().getTime())
+                   );
+        return 0;
+    }
+
+    // ********************** Business Methods ********************** //
+
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/model/User.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountCompositeUserType.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountCompositeUserType.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountCompositeUserType.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,114 @@
+package auction.persistence;
+
+import org.hibernate.*;
+import org.hibernate.usertype.CompositeUserType;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.type.Type;
+import auction.model.MonetaryAmount;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.sql.*;
+import java.util.Currency;
+
+/**
+ * This is a simple Hibernate custom mapping type for MonetaryAmount value types.
+ * <p>
+ * Basically the same as the simple <tt>MonetaryAmountSimpleUserType</tt>, but
+ * implementing the Hibernate <tt>CompositeUserType</tt> interface. This interface
+ * has some additional methods that allow Hibernate to analyze the value type you
+ * are mapping. This is mostly useful for HQL queries: with this custom mapping
+ * type, you can use the "amount" and "currency" sub-components in HQL queries.
+ *
+ * @see MonetaryAmountSimpleUserType
+ * @author Christian Bauer
+ */
+public class MonetaryAmountCompositeUserType
+		implements CompositeUserType {
+
+    public Class returnedClass() { return MonetaryAmount.class; }
+
+    public boolean isMutable() { return false; }
+
+    public Object deepCopy(Object value) {
+        return value;
+    }
+
+    public Serializable disassemble(Object value, SessionImplementor session) {
+        return (Serializable) value;
+    }
+
+    public Object assemble(Serializable cached, SessionImplementor session, Object owner) {
+        return cached;
+    }
+
+    public Object replace(Object original, Object target, SessionImplementor session, Object owner) {
+        return original;
+    }
+
+    public boolean equals(Object x, Object y) {
+        if (x == y) return true;
+        if (x == null || y == null) return false;
+        return x.equals(y);
+    }
+
+    public int hashCode(Object x) {
+        return x.hashCode();
+    }
+
+    public Object nullSafeGet(ResultSet resultSet,
+                              String[] names,
+                              SessionImplementor session,
+                              Object owner)
+            throws SQLException {
+
+        BigDecimal value = resultSet.getBigDecimal( names[0] );
+        if (resultSet.wasNull()) return null;
+        Currency currency =
+            Currency.getInstance(resultSet.getString( names[1] ) );
+        return new MonetaryAmount(value, currency);
+    }
+
+    public void nullSafeSet(PreparedStatement statement,
+                            Object value,
+                            int index,
+                            SessionImplementor session)
+        throws SQLException {
+
+        if (value==null) {
+            statement.setNull(index, Hibernate.BIG_DECIMAL.sqlType());
+            statement.setNull(index+1, Hibernate.CURRENCY.sqlType());
+        } else {
+            MonetaryAmount amount = (MonetaryAmount) value;
+            String currencyCode =
+                        amount.getCurrency().getCurrencyCode();
+            statement.setBigDecimal( index, amount.getValue() );
+            statement.setString( index+1, currencyCode );
+        }
+    }
+
+	public String[] getPropertyNames() {
+		return new String[] { "value", "currency" };
+	}
+
+	public Type[] getPropertyTypes() {
+		return new Type[] { Hibernate.BIG_DECIMAL,
+                            Hibernate.CURRENCY };
+	}
+
+	public Object getPropertyValue(Object component,
+								   int property) {
+        MonetaryAmount monetaryAmount = (MonetaryAmount) component;
+        if (property == 0)
+            return monetaryAmount.getValue();
+        else
+            return monetaryAmount.getCurrency();
+	}
+
+	public void setPropertyValue(Object component,
+								 int property,
+								 Object value) {
+       throw new UnsupportedOperationException("MonetaryAmount is immutable");
+	}
+
+}
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountCompositeUserType.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountSimpleUserType.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountSimpleUserType.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountSimpleUserType.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,85 @@
+package auction.persistence;
+
+import org.hibernate.*;
+import org.hibernate.usertype.UserType;
+import auction.model.*;
+
+import java.math.BigDecimal;
+import java.sql.*;
+import java.util.Currency;
+import java.io.Serializable;
+
+/**
+ * This is a simple Hibernate custom mapping type for MonetaryAmount value types.
+ * <p>
+ * Note that this mapping type is for legacy databases that only have a
+ * single numeric column to hold monetary amounts. Every <tt>MonetaryAmount</tt>
+ * will be converted to USD (using some conversion magic of the class itself)
+ * and saved to the database.
+ *
+ * @author Christian Bauer
+ */
+public class MonetaryAmountSimpleUserType
+		implements UserType {
+
+	public int[] sqlTypes() {
+        return new int[]{ Hibernate.BIG_DECIMAL.sqlType() };
+    }
+
+	public Class returnedClass() { return MonetaryAmount.class; }
+
+	public boolean isMutable() { return false; }
+
+	public Object deepCopy(Object value) {
+		return value;
+	}
+
+    public Serializable disassemble(Object value) {
+        return (Serializable) value;
+    }
+
+    public Object assemble(Serializable cached, Object owner) {
+        return cached;
+    }
+
+    public Object replace(Object original, Object target, Object owner) {
+        return original;
+    }
+
+    public boolean equals(Object x, Object y) {
+        if (x == y) return true;
+        if (x == null || y == null) return false;
+        return x.equals(y);
+    }
+
+    public int hashCode(Object x) {
+        return x.hashCode();
+    }
+
+	public Object nullSafeGet(ResultSet resultSet,
+							  String[] names,
+							  Object owner)
+			throws HibernateException, SQLException {
+
+		BigDecimal valueInUSD = resultSet.getBigDecimal(names[0]);
+        if (resultSet.wasNull()) return null;
+		Currency userCurrency = Currency.getInstance("USD");
+		return new MonetaryAmount(valueInUSD, userCurrency);
+	}
+
+	public void nullSafeSet(PreparedStatement statement,
+							Object value,
+							int index)
+			throws HibernateException, SQLException {
+
+		if (value == null) {
+			statement.setNull(index, Hibernate.BIG_DECIMAL.sqlType());
+		} else {
+			MonetaryAmount anyCurrency = (MonetaryAmount)value;
+			MonetaryAmount amountInUSD =
+			  MonetaryAmount.convert( anyCurrency,
+									  Currency.getInstance("USD") );
+			statement.setBigDecimal(index, amountInUSD.getValue());
+		}
+	}
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountSimpleUserType.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountType.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountType.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountType.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,59 @@
+package auction.persistence;
+
+import org.hibernate.usertype.*;
+import auction.model.MonetaryAmount;
+import org.hibernate.*;
+import org.hibernate.engine.SessionImplementor;
+
+import java.util.*;
+import java.sql.*;
+import java.math.BigDecimal;
+
+/**
+ * This type adds parameterizable currency conversion to the normal composite user type,
+ * that is, you can set the target currency for the conversion (for the value saved and
+ * loaded from the database) to any ISO code in your mapping, depending on the
+ * situation/property to map. It maps a two-attribute component to two database columns.
+ *
+ * @see MonetaryAmountSimpleUserType
+ * @author Christian Bauer
+ */public class MonetaryAmountType extends MonetaryAmountCompositeUserType implements ParameterizedType {
+
+	// The amount
+	private Currency convertTo;
+
+	public void setParameterValues(Properties parameters) {
+		this.convertTo = Currency.getInstance(parameters.getProperty("convertTo"));
+	}
+
+	public Object nullSafeGet(ResultSet resultSet,
+							  String[] names,
+							  SessionImplementor session,
+							  Object owner)
+			throws HibernateException, SQLException {
+
+		if (resultSet.wasNull()) return null;
+		BigDecimal value = resultSet.getBigDecimal( names[0] );
+        // When loading, take the currency from the database
+		Currency currency = Currency.getInstance(resultSet.getString( names[1] ) );
+        return new MonetaryAmount(value, currency);
+	}
+
+	public void nullSafeSet(PreparedStatement statement,
+							Object value,
+							int index,
+							SessionImplementor session)
+			throws HibernateException, SQLException {
+
+		if (value==null) {
+		    statement.setNull(index, Types.NUMERIC);
+		} else {
+		    MonetaryAmount amount = (MonetaryAmount) value;
+            // When saving, convert to target currency
+		    MonetaryAmount dbAmount = MonetaryAmount.convert(amount, convertTo);
+		    statement.setBigDecimal( index, dbAmount.getValue() );
+            statement.setString( index+1, convertTo.getCurrencyCode());
+		}
+	}
+	
+}
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/MonetaryAmountType.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/package-info.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/package-info.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/package-info.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,26 @@
+ at org.hibernate.annotations.TypeDefs({
+    @org.hibernate.annotations.TypeDef(
+        name="monetary_amount_usd",
+        typeClass = MonetaryAmountType.class,
+        parameters = { @org.hibernate.annotations.Parameter(name="convertTo", value="USD") }
+    ),
+    @org.hibernate.annotations.TypeDef(
+        name="monetary_amount_eur",
+        typeClass = MonetaryAmountType.class,
+        parameters = { @org.hibernate.annotations.Parameter(name="convertTo", value="EUR") }
+    )
+})
+
+ at org.hibernate.annotations.FilterDefs({
+    @org.hibernate.annotations.FilterDef(
+        name="limitItemsByUserRank",
+        parameters = {
+            @org.hibernate.annotations.ParamDef(
+                name = "currentUserRank", type = "int"
+            )
+        }
+    )
+})
+
+
+package auction.persistence;


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/persistence/package-info.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/EJB3IntegrationTest.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/EJB3IntegrationTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/EJB3IntegrationTest.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,155 @@
+package auction.test;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.io.InputStream;
+import java.io.File;
+import java.sql.Connection;
+
+import org.dbunit.dataset.*;
+import org.dbunit.dataset.xml.FlatXmlDataSet;
+import org.dbunit.operation.DatabaseOperation;
+import org.dbunit.database.*;
+import org.testng.annotations.*;
+import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
+
+import javax.naming.*;
+import javax.sql.DataSource;
+import javax.transaction.UserTransaction;
+import javax.persistence.EntityManagerFactory;
+
+public abstract class EJB3IntegrationTest {
+
+    // Configuration options
+    private String JNDI_DATASOURCE;
+    private String JNDI_NAME_EMF;
+    private String JNDI_NAME_USERTX;
+
+    protected InitialContext jndi;
+
+    protected String dataSetLocation;
+    protected List<DatabaseOperation> beforeTestOperations
+            = new ArrayList<DatabaseOperation>();
+    protected List<DatabaseOperation> afterTestOperations
+            = new ArrayList<DatabaseOperation>();
+
+    private ReplacementDataSet dataSet;
+
+    @BeforeTest(groups = "integration-persistence")
+    @Parameters({"deploy_beans_xml", "scan_classpath",
+                 "jndi_datasource", "jndi_name_emf", "jndi_name_usertx"})
+    public void startContainer(String deployBeansXml, String scanClasspath,
+                               String jndiDatasource, String jndiNameEMF, String jndiNameUserTx)
+            throws Exception {
+        // Set configuration options from TestNG parameters
+        JNDI_DATASOURCE = jndiDatasource;
+        JNDI_NAME_EMF = jndiNameEMF;
+        JNDI_NAME_USERTX = jndiNameUserTx;
+
+        // Boot the JBoss Microcontainer with EJB3 settings, automatically
+        // loads ejb3-interceptors-aop.xml and embedded-jboss-beans.xml
+        EJB3StandaloneBootstrap.boot(null);
+
+        // Deploy custom stateless beans (datasource, mostly)
+        EJB3StandaloneBootstrap.deployXmlResource(deployBeansXml);
+
+        // Deploy all EJBs found on classpath (slow, scans all)
+        //EJB3StandaloneBootstrap.scanClasspath();
+
+        // Deploy all EJBs found on classpath (fast, scans only build directory)
+        // This is a relative location, matching the substring end of one of java.class.path locations!
+        // Print out System.getProperty("java.class.path") to understand this...
+        EJB3StandaloneBootstrap.scanClasspath(scanClasspath.replace("/", File.separator));
+
+        // Create InitialContext from jndi.properties
+        jndi = new InitialContext();
+    }
+
+    @BeforeClass(groups = "integration-persistence")
+    public void prepareDataSet() throws Exception {
+
+        // Check if subclass has prepared everything
+        prepareSettings();
+        if (dataSetLocation == null)
+            throw new RuntimeException(
+                "Test subclass needs to prepare a dataset location"
+            );
+
+        // Load the base dataset file
+        InputStream input =
+                Thread.currentThread().getContextClassLoader()
+                        .getResourceAsStream(dataSetLocation);
+
+        dataSet = new ReplacementDataSet(
+                        new FlatXmlDataSet(input)
+                      );
+        dataSet.addReplacementObject("[NULL]", null);
+    }
+
+    @BeforeMethod(groups = "integration-persistence")
+    public void beforeTestMethod() throws Exception {
+        prepareSettings();
+        for (DatabaseOperation op : beforeTestOperations ) {
+            op.execute(getConnection(), dataSet);
+        }
+    }
+
+    @AfterMethod(groups = "integration-persistence")
+    public void afterTestMethod() throws Exception {
+        for (DatabaseOperation op : afterTestOperations ) {
+            op.execute(getConnection(), dataSet);
+        }
+    }
+
+    // Convenience for subclasses
+
+    protected UserTransaction getUserTransaction() throws Exception {
+        return (UserTransaction)jndi.lookup(JNDI_NAME_USERTX);
+    }
+
+    protected EntityManagerFactory getEntityManagerFactory() throws Exception{
+        return (EntityManagerFactory)jndi.lookup(JNDI_NAME_EMF);
+    }
+
+    @SuppressWarnings({"unchecked"})
+    protected <T> T lookupLocalBean(Class<T> beanInterface, String beanImpl) {
+        try {
+            return (T)jndi.lookup(beanImpl + "/local");
+        } catch (NamingException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    // Subclasses can/have to override the following methods
+
+    protected IDatabaseConnection getConnection() throws Exception {
+
+        // Get a JDBC connection from JNDI datasource
+        Connection con = ((DataSource) jndi.lookup(JNDI_DATASOURCE)).getConnection();
+
+        // Disable foreign key constraint checking
+        // This really depends on the DBMS product... here for HSQL DB
+        con.prepareStatement("set referential_integrity FALSE")
+            .execute();
+
+        IDatabaseConnection dbUnitCon =
+            new DatabaseConnection( con);
+
+        // TODO: Remove this once DBUnit works with the latest HSQL DB
+        DatabaseConfig config = dbUnitCon.getConfig();
+        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new FixDBUnit());
+
+        return dbUnitCon;
+    }
+
+    /**
+     * Override this in a subclass. It will be called before each test
+     * method. Use it to stack DBUnit <tt>DatabaseOperation</tt>'s with
+     * the <tt>beforeTestOperations</tt> and <tt>afterTestOperations</tt>
+     * lists. You can also modify the <tt>afterTestOperations</tt> list
+     * <i>inside</i> a test method, if you require additional clean up
+     * once the method completes.
+     */
+    protected abstract void prepareSettings();
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/EJB3IntegrationTest.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/FixDBUnit.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/FixDBUnit.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/FixDBUnit.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,21 @@
+package auction.test;
+
+import org.dbunit.dataset.datatype.*;
+
+import java.sql.Types;
+
+/**
+ * TODO: Direct SQL is lots of fun. This fixes DBUnit with the latest HSQL DB.
+ *
+ * http://www.carbonfive.com/community/archives/2005/07/dbunit_hsql_and.html
+ */
+public class FixDBUnit extends DefaultDataTypeFactory {
+
+   public DataType createDataType(int sqlType, String sqlTypeName)
+     throws DataTypeException {
+      if (sqlType == Types.BOOLEAN) {
+         return DataType.BOOLEAN;
+       }
+      return super.createDataType(sqlType, sqlTypeName);
+    }
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/FixDBUnit.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/TestUtil.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/TestUtil.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/TestUtil.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,137 @@
+package auction.test;
+
+import javax.naming.*;
+import java.lang.reflect.Proxy;
+
+/**
+ * Some helper methods for testing.
+ *
+ * @author Christian Bauer
+ */
+public class TestUtil {
+
+    public static String listJNDITree(String namespace) {
+        StringBuffer buffer = new StringBuffer(4096);
+        try {
+            Context context = new InitialContext(); // From jndi.properties
+            if (namespace!= null)
+                context = (Context) context.lookup(namespace);
+            buffer.append("Namespace: " + namespace +"\n");
+            buffer.append("#####################################\n");
+            list(context, " ", buffer, true);
+            buffer.append("#####################################\n");
+        }
+        catch (NamingException e) {
+            buffer.append("Failed to get InitialContext, " + e.toString(true));
+        }
+        return buffer.toString();
+    }
+
+    private static void list(Context ctx, String indent, StringBuffer buffer, boolean verbose) {
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        try {
+            NamingEnumeration ne = ctx.list("");
+            while (ne.hasMore()) {
+                NameClassPair pair = (NameClassPair) ne.next();
+
+                String name = pair.getName();
+                String className = pair.getClassName();
+                boolean recursive = false;
+                boolean isLinkRef = false;
+                boolean isProxy = false;
+                Class c = null;
+                try {
+                    c = loader.loadClass(className);
+
+                    if (Context.class.isAssignableFrom(c))
+                        recursive = true;
+                    if (LinkRef.class.isAssignableFrom(c))
+                        isLinkRef = true;
+
+                    isProxy = Proxy.isProxyClass(c);
+                }
+                catch (ClassNotFoundException cnfe) {
+                    // If this is a $Proxy* class its a proxy
+                    if (className.startsWith("$Proxy")) {
+                        isProxy = true;
+                        // We have to get the class from the binding
+                        try {
+                            Object p = ctx.lookup(name);
+                            c = p.getClass();
+                        }
+                        catch (NamingException e) {
+                            Throwable t = e.getRootCause();
+                            if (t instanceof ClassNotFoundException) {
+                                // Get the class name from the exception msg
+                                String msg = t.getMessage();
+                                if (msg != null) {
+                                    // Reset the class name to the CNFE class
+                                    className = msg;
+                                }
+                            }
+                        }
+                    }
+                }
+
+                buffer.append(indent + " +- " + name);
+
+                // Display reference targets
+                if (isLinkRef) {
+                    // Get the
+                    try {
+                        Object obj = ctx.lookupLink(name);
+
+                        LinkRef link = (LinkRef) obj;
+                        buffer.append("[link -> ");
+                        buffer.append(link.getLinkName());
+                        buffer.append(']');
+                    }
+                    catch (Throwable t) {
+                        buffer.append("invalid]");
+                    }
+                }
+
+                // Display proxy interfaces
+                if (isProxy) {
+                    buffer.append(" (proxy: " + pair.getClassName());
+                    if (c != null) {
+                        Class[] ifaces = c.getInterfaces();
+                        buffer.append(" implements ");
+                        for (int i = 0; i < ifaces.length; i++) {
+                            buffer.append(ifaces[i]);
+                            buffer.append(',');
+                        }
+                        buffer.setCharAt(buffer.length() - 1, ')');
+                    } else {
+                        buffer.append(" implements " + className + ")");
+                    }
+                } else if (verbose) {
+                    buffer.append(" (class: " + pair.getClassName() + ")");
+                }
+
+                buffer.append('\n');
+                if (recursive) {
+                    try {
+                        Object value = ctx.lookup(name);
+                        if (value instanceof Context) {
+                            Context subctx = (Context) value;
+                            list(subctx, indent + " |  ", buffer, verbose);
+                        } else {
+                            buffer.append(indent + " |   NonContext: " + value);
+                            buffer.append('\n');
+                        }
+                    }
+                    catch (Throwable t) {
+                        buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage());
+                        buffer.append('\n');
+                    }
+                }
+            }
+            ne.close();
+        }
+        catch (NamingException ne) {
+            buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true));
+        }
+    }
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/TestUtil.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basedata.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basedata.xml	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basedata.xml	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,168 @@
+<?xml version="1.0"?>
+
+<!--
+    Just a basic set of rows that are currently sufficient for all tests.
+    In future, maybe several datasets are required.
+-->
+<dataset>
+
+    <BILLING_DETAILS
+        BILLING_DETAILS_ID      ="1"
+        BILLING_DETAILS_TYPE    ="CC"
+        OBJ_VERSION             ="0"
+        OWNER                   ="John Doe"
+        CREATED                 ="2006-09-23 13:45:00"
+        USER_ID                 ="1"
+        BA_ACCOUNT              ="[NULL]"
+        BA_BANKNAME             ="[NULL]"
+        BA_SWIFT                ="[NULL]"
+    />
+
+    <CREDIT_CARD CREDIT_CARD_ID     ="1"
+                 CC_TYPE            ="MASTERCARD"
+                 CC_NUMBER          ="123123123123"
+                 CC_EXP_MONTH       ="08"
+                 CC_EXP_YEAR        ="2010"
+            />
+
+    <USERS
+        USER_ID             ="1"
+        OBJ_VERSION         ="0"
+        FIRSTNAME           ="John"
+        LASTNAME            ="Doe"
+        USERNAME            ="johndoe"
+        PASSWORD            ="secret"
+        EMAIL               ="jd at mail.tld"
+        RANK                ="0"
+        IS_ADMIN            ="true"
+        CREATED             ="2006-09-23 13:45:00"
+        HOME_STREET         ="Foostreet"
+        HOME_ZIPCODE        ="22222"
+        HOME_CITY           ="Foocity"
+        DEFAULT_BILLING_DETAILS_ID ="1"
+    />
+
+    <USERS
+        USER_ID             ="2"
+        OBJ_VERSION         ="0"
+        FIRSTNAME           ="Another"
+        LASTNAME            ="User"
+        USERNAME            ="anotheruser"
+        PASSWORD            ="secret"
+        EMAIL               ="anotheruser at mail.tld"
+        RANK                ="0"
+        IS_ADMIN            ="false"
+        CREATED             ="2006-09-23 13:45:00"
+        HOME_STREET         ="Foostreet"
+        HOME_ZIPCODE        ="22222"
+        HOME_CITY           ="Foocity"
+        DEFAULT_BILLING_DETAILS_ID ="[NULL]"
+    />
+
+    <ADDRESS
+        ADDRESS_ID      ="1"
+        OBJ_VERSION     ="0"
+        STREET          ="Shippingstreet 1"
+        ZIPCODE         ="12345"
+        CITY            ="Shippingcity"
+    />
+
+    <ITEM
+        ITEM_ID                 ="1"
+        OBJ_VERSION             ="0"
+        ITEM_NAME               ="Testitem 1"
+        DESCRIPTION             ="This is TestItem One."
+        INITIAL_PRICE           ="99"
+        INITIAL_PRICE_CURRENCY  ="USD"
+        RESERVE_PRICE           ="123"
+        RESERVE_PRICE_CURRENCY  ="USD"
+        START_DATE              ="2006-09-23 13:45:00"
+        END_DATE                ="2016-09-23 13:45:00"
+        ITEM_STATE              ="ACTIVE"
+        APPROVED_BY_USER_ID     ="1"
+        APPROVAL_DATETIME       ="2006-09-23 13:45:00"
+        SELLER_ID               ="1"
+        SUCCESSFUL_BID_ID       ="2"
+        CREATED                 ="2006-09-23 13:45:00"
+    />
+
+    <ITEM
+        ITEM_ID                 ="2"
+        OBJ_VERSION             ="0"
+        ITEM_NAME               ="Testitem 2"
+        DESCRIPTION             ="This is TestItem Two."
+        INITIAL_PRICE           ="111"
+        INITIAL_PRICE_CURRENCY  ="USD"
+        RESERVE_PRICE           ="222"
+        RESERVE_PRICE_CURRENCY  ="USD"
+        START_DATE              ="2006-09-23 13:45:00"
+        END_DATE                ="2016-09-23 13:45:00"
+        ITEM_STATE              ="DRAFT"
+        APPROVED_BY_USER_ID     ="1"
+        APPROVAL_DATETIME       ="2006-09-23 13:45:00"
+        SELLER_ID               ="1"
+        SUCCESSFUL_BID_ID       ="[NULL]"
+        CREATED                 ="2006-09-23 13:45:00"
+    />
+
+    <BID
+        BID_ID                  ="1"
+        BID_AMOUNT              ="100"
+        BID_AMOUNT_CURRENCY     ="USD"
+        ITEM_ID                 ="1"
+        BIDDER_ID               ="1"
+        BID_POSITION            ="0"
+        CREATED                 ="2006-09-23 13:46:00"
+    />
+
+    <BID
+        BID_ID                  ="2"
+        BID_AMOUNT              ="124"
+        BID_AMOUNT_CURRENCY     ="USD"
+        ITEM_ID                 ="1"
+        BIDDER_ID               ="1"
+        BID_POSITION            ="1"
+        CREATED                 ="2006-09-23 13:47:00"
+    />
+
+    <CATEGORY
+        CATEGORY_ID             ="1"
+        OBJ_VERSION             ="0"
+        CATEGORY_NAME           ="Category One"
+        CREATED                 ="2006-09-23 13:45:00"
+        PARENT_CATEGORY_ID      ="[NULL]"
+    />
+
+    <CATEGORY
+        CATEGORY_ID             ="2"
+        OBJ_VERSION             ="0"
+        CATEGORY_NAME           ="Category Two"
+        CREATED                 ="2006-09-23 13:45:00"
+        PARENT_CATEGORY_ID      ="1"
+    />
+
+    <CATEGORIZED_ITEM
+        CATEGORY_ID             ="1"
+        ITEM_ID                 ="1"
+        ADDED_BY_USER           ="johndoe"
+        ADDED_ON                ="2006-09-23 13:45:00"
+    />
+
+    <CATEGORIZED_ITEM
+        CATEGORY_ID             ="2"
+        ITEM_ID                 ="1"
+        ADDED_BY_USER           ="johndoe"
+        ADDED_ON                ="2006-09-23 13:45:00"
+    />
+
+    <COMMENT
+        COMMENT_ID              ="1"
+        OBJ_VERSION             ="0"
+        RATING                  ="OK"
+        COMMENT_TEXT            ="Just a comment."
+        ABOUT_ITEM_ID           ="1"
+        FROM_USER_ID            ="1"
+        CREATED                 ="2006-09-23 13:47:00"
+    />
+
+</dataset>


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basedata.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basic/PersistentStateTransitions.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basic/PersistentStateTransitions.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basic/PersistentStateTransitions.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,171 @@
+package auction.test.basic;
+
+import org.dbunit.operation.DatabaseOperation;
+
+import org.testng.annotations.*;
+
+import java.util.*;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import auction.dao.ItemDAO;
+import auction.dao.UserDAO;
+import auction.dao.ejb3.GenericEJB3DAO;
+import auction.dao.ejb3.ItemDAOBean;
+import auction.dao.ejb3.UserDAOBean;
+import auction.model.User;
+import auction.model.Item;
+import auction.model.MonetaryAmount;
+import auction.test.EJB3IntegrationTest;
+
+import javax.persistence.EntityManager;
+import javax.persistence.SqlResultSetMapping;
+import javax.persistence.ColumnResult;
+import javax.transaction.UserTransaction;
+
+// For validation query in native SQL
+ at SqlResultSetMapping(
+    name = "PriceSellerResult",
+    columns = {
+        @ColumnResult(name = "IP"),
+        @ColumnResult(name = "SID")
+
+    }
+)
+
+public class PersistentStateTransitions extends EJB3IntegrationTest {
+
+    protected void prepareSettings() {
+        dataSetLocation = "auction/test/basedata.xml";
+        beforeTestOperations.add(DatabaseOperation.CLEAN_INSERT);
+    }
+
+    /**
+     * This test doesn't really need the EJB container, it starts a UserTransaction
+     * manually and instantiates DAOs directly. However, the datasource is still
+     * managed by the container. The EntityManagerFactory is also handled by the
+     * container.
+     */
+    @Test(groups = "integration-persistence")
+    public void withoutEJBContainer() throws Exception {
+
+        // Start a unit of work (manually, no container)
+        UserTransaction ut = getUserTransaction();
+        
+        ut.begin();
+        EntityManager em = getEntityManagerFactory().createEntityManager();
+
+        
+        // Prepare the DAOs (manually, no Seam)
+        ItemDAO itemDAO = new ItemDAOBean();
+        ((GenericEJB3DAO) itemDAO).setEntityManager(em);
+
+        UserDAO userDAO = new UserDAOBean();
+        ((GenericEJB3DAO) userDAO).setEntityManager(em);
+
+        // Prepare a user object
+        User user = userDAO.findById(1l, false);
+
+        // Make a new auction item persistent
+        Calendar startDate = GregorianCalendar.getInstance();
+        Calendar endDate = GregorianCalendar.getInstance();
+        endDate.add(Calendar.DAY_OF_YEAR, 3);
+
+        MonetaryAmount initialPrice =
+            new MonetaryAmount(new BigDecimal(123), Currency.getInstance("USD"));
+        MonetaryAmount reservePrice =
+            new MonetaryAmount(new BigDecimal(333), Currency.getInstance("USD"));
+
+        Item newItem =
+            new Item( "Testitem", "Test Description", user,
+                      initialPrice, reservePrice,
+                      startDate.getTime(), endDate.getTime() );
+
+        // Don't forget to take the return value, this is basically a merge()
+        newItem = itemDAO.makePersistent(newItem);
+
+        // End the unit of work
+        getUserTransaction().commit();
+        em.close();
+
+
+        // Direct SQL query for database state in auto-commit mode
+        em = getEntityManagerFactory().createEntityManager();
+        Object[] result = (Object[])
+                em.createNativeQuery(
+                        "select INITIAL_PRICE as IP," +
+                        "       SELLER_ID as SID from ITEM where ITEM_ID = :itemId")
+                        .setParameter("itemId", newItem.getId())
+                        .getSingleResult();
+        em.close();
+
+
+        // Assert correctness of state
+        assert result[0].getClass() == BigDecimal.class;
+        assert result[0].equals(newItem.getInitialPrice().getValue());
+        // The SQL resultset mapping returns a BigInteger
+        assert result[1].equals(new BigInteger("1"));
+
+    }
+
+    /**
+     * This test looks up the DAOs as managed EJBs. The DAOs will have the
+     * current persistence context injected automatically, the persistence
+     * context is scoped and bound to the JTA transaction.
+     */
+    @Test(groups = "integration-persistence")
+    public void withEJBContainer() throws Exception {
+
+        // Start a unit of work (manually, no Seam)
+        getUserTransaction().begin();
+
+        // Prepare the DAOs (manually, no Seam)
+        ItemDAO itemDAO = lookupLocalBean(ItemDAO.class, "ItemDAOBean");
+        UserDAO userDAO = lookupLocalBean(UserDAO.class, "UserDAOBean");
+
+        // Prepare a user object
+        User user = userDAO.findById(1l, false);
+
+        // Make a new auction item persistent
+        Calendar startDate = GregorianCalendar.getInstance();
+        Calendar endDate = GregorianCalendar.getInstance();
+        endDate.add(Calendar.DAY_OF_YEAR, 3);
+
+        MonetaryAmount initialPrice =
+            new MonetaryAmount(new BigDecimal(123), Currency.getInstance("USD"));
+        MonetaryAmount reservePrice =
+            new MonetaryAmount(new BigDecimal(333), Currency.getInstance("USD"));
+
+        Item newItem =
+            new Item( "Testitem", "Test Description", user,
+                      initialPrice, reservePrice,
+                      startDate.getTime(), endDate.getTime() );
+
+        // Don't forget to take the return value, this is basically a merge()
+        newItem = itemDAO.makePersistent(newItem);
+
+        // End the unit of work
+        getUserTransaction().commit();
+
+
+        // Direct SQL query for database state in auto-commit mode
+        EntityManager em = getEntityManagerFactory().createEntityManager();
+        Object[] result = (Object[])
+                em.createNativeQuery(
+                        "select INITIAL_PRICE as IP," +
+                        "       SELLER_ID as SID from ITEM where ITEM_ID = :itemId")
+                        .setParameter("itemId", newItem.getId())
+                        .getSingleResult();
+        em.close();
+
+
+        // Assert correctness of state
+        assert result[0].getClass() == BigDecimal.class;
+        assert result[0].equals(newItem.getInitialPrice().getValue());
+        // The SQL resultset mapping returns a BigInteger
+        assert result[1].equals(new BigInteger("1"));
+
+    }
+
+
+}


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/auction/test/basic/PersistentStateTransitions.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/AbstractMVCCEvent.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/AbstractMVCCEvent.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/AbstractMVCCEvent.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,16 @@
+package uk.ac.ncl.sdia.a8905943.event;
+
+import org.codehaus.multiverse.multiversionedstm.MultiversionedStm;
+
+public abstract class AbstractMVCCEvent {
+
+	private static MultiversionedStm stm = null;
+	static{
+		stm = new MultiversionedStm();
+	}
+	
+	public MultiversionedStm getStm()
+	{
+		return stm;
+	}
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/MVCCLoadEventListener.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/MVCCLoadEventListener.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/MVCCLoadEventListener.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,52 @@
+package uk.ac.ncl.sdia.a8905943.event;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.multiverse.api.Transaction;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.EntityKey;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.event.LoadEvent;
+import org.hibernate.event.LoadEventListener;
+import org.hibernate.event.def.DefaultLoadEventListener;
+import org.hibernate.persister.entity.EntityPersister;
+
+import uk.ac.ncl.sdia.a8905943.mapping.MappingSessionMVCC;
+
+public class MVCCLoadEventListener extends DefaultLoadEventListener {
+
+	private static final long serialVersionUID = 5162596964232539158L;
+	private static final Log log = LogFactory.getLog(MVCCLoadEventListener.class);
+	private static MappingSessionMVCC mapping = new MappingSessionMVCC();
+
+	protected Object loadFromDatasource(
+			final LoadEvent event,
+			final EntityPersister persister,
+			final EntityKey keyToLoad,
+			final LoadEventListener.LoadType options) throws HibernateException
+	{
+		final SessionImplementor source = event.getSession();
+        final boolean stats = source.getFactory().getStatistics().isStatisticsEnabled();
+        long startTime = 0;
+        if ( stats ) startTime = System.currentTimeMillis();
+
+        Transaction transaction = mapping.getTransaction(event.getSession());
+        transaction.l
+        
+        /*
+        Object entity = persister.load(
+				event.getEntityId(),
+				event.getInstanceToLoad(),
+				event.getLockMode(),
+				source
+		);
+		*/
+
+		if ( event.isAssociationFetch() && stats) {
+			source.getFactory().getStatisticsImplementor().fetchEntity( event.getEntityClassName(), System.currentTimeMillis() - startTime);
+		}
+
+		//return entity;
+		return null;
+	}
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/MVCCSaveOrUpdateEvent.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/MVCCSaveOrUpdateEvent.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/event/MVCCSaveOrUpdateEvent.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,21 @@
+package uk.ac.ncl.sdia.a8905943.event;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.multiverse.multiversionedstm.MultiversionedStm.MultiversionedTransactionImpl;
+import org.hibernate.HibernateException;
+import org.hibernate.event.SaveOrUpdateEvent;
+import org.hibernate.event.SaveOrUpdateEventListener;
+
+public class MVCCSaveOrUpdateEvent extends AbstractMVCCEvent implements SaveOrUpdateEventListener {
+
+	private static final long serialVersionUID = 1368413908515690348L;
+	private static final Log log = LogFactory.getLog(MVCCSaveOrUpdateEvent.class);
+
+	public void onSaveOrUpdate(SaveOrUpdateEvent event)
+			throws HibernateException {
+		 MultiversionedTransactionImpl impl = getStm().startTransaction();
+		 
+	}
+
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCTransaction.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCTransaction.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCTransaction.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,18 @@
+package uk.ac.ncl.sdia.a8905943.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MVCCTransaction {
+
+	private Map<String, Map<String, Object>> store = new HashMap<String, Map<String, Object>>();
+	public Object read(String identity, String name, Object object)
+	{
+		return store.get(name).get(identity);
+	}
+	public void write()
+	{
+		
+	}
+	
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/SessionMapper.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/SessionMapper.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/impl/SessionMapper.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,27 @@
+package uk.ac.ncl.sdia.a8905943.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.Session;
+
+/** The purpose of this object is to map the Hibernate Session object and the 
+ * Transaction object.
+ * First attempt at getting something together. 
+ * 
+ * @author whitingjr
+ *
+ */
+public class SessionMapper {
+
+	private static Map<Session, MVCCTransaction> mapping = new HashMap<Session, MVCCTransaction>();
+
+	public static Map<Session, MVCCTransaction> getMapping() {
+		return mapping;
+	}
+	public void add(Session session, MVCCTransaction transaction)
+	{
+		mapping.put(session, transaction);
+	}
+	
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/HandleUtils.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/HandleUtils.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/HandleUtils.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,20 @@
+package uk.ac.ncl.sdia.a8905943.mapping;
+
+/**
+ * Convenience object to get handles.
+ * @author whitingjr
+ *
+ */
+public class HandleUtils {
+
+	/**
+	 * 
+	 * Use this method to generate a handle based on an object the user has requested to
+	 * load.
+	 * @return long representing a handle that represents the mapping on the Hibernate side.
+	 */
+	public static long getHibernateHandle()
+	{
+		
+	}
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/MappingHandles.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/MappingHandles.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/MappingHandles.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,14 @@
+package uk.ac.ncl.sdia.a8905943.mapping;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MappingHandles {
+
+	private Map<Long, Long> handles = new HashMap<Long, Long>();
+	
+	public Long getTransactionHandle(Long _hibernateHandle)
+	{
+		return handles.get(_hibernateHandle	);
+	}
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/MappingSessionMVCC.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/MappingSessionMVCC.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/mapping/MappingSessionMVCC.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,56 @@
+package uk.ac.ncl.sdia.a8905943.mapping;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.codehaus.multiverse.api.Transaction;
+import org.codehaus.multiverse.multiversionedstm.MultiversionedStm;
+import org.hibernate.Session;
+/**
+ * Use this object to hold a mapping between a Hibernate Session object and an
+ * STM Transaction object. Not convinced this is the right strategy but have to 
+ * start somewhere.
+ * Made the objects static so they are shared across jvm, assumption is there is 
+ * only one JVM in use. Not distributed nor thread safe.
+ * @author whitingjr
+ *
+ */
+
+public class MappingSessionMVCC {
+
+	private static Map<Session, Transaction> mapping;
+	private static MultiversionedStm stm;
+	private static MappingHandles handles;
+	static
+	{
+		mapping = new HashMap<Session, Transaction> ();
+		stm = new MultiversionedStm();
+		handles = new MappingHandles();
+	}
+	
+	/** Use this method to retrieve the transaction associated with the Session. If non
+	 * is found the create a new Transaction.
+	 */
+	public Transaction getTransaction(Session _session)
+	{
+		Transaction returnValue = null;
+		if (mapping.containsKey(_session))
+		{
+			returnValue = mapping.get(_session);
+		}
+		else
+		{
+			returnValue = stm.startTransaction();
+			mapping.put(_session, returnValue);
+		}
+		
+		return returnValue;
+	}
+	public Transaction removeTransaction(Session _session)
+	{
+		return mapping.remove(_session);
+	}
+	
+	
+
+ }

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/model/CompositeObjectHandle.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/model/CompositeObjectHandle.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/model/CompositeObjectHandle.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,58 @@
+package uk.ac.ncl.sdia.a8905943.model;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+/**
+ * @deprecated
+ * @author whitingjr
+ *
+ * @param <T>
+ */
+public class CompositeObjectHandle <T> implements Serializable {
+
+	private static final long serialVersionUID = 9164138713657231435L;
+	private long handle;
+	private T obj;
+	public long getHandle() {
+		return handle;
+	}
+	public void setHandle(long handle) {
+		this.handle = handle;
+	}
+	public T getObj() {
+		return obj;
+	}
+	public void setObj(T obj) {
+		this.obj = obj;
+	}
+	
+	@Override
+	public boolean equals(Object obj) 
+	{
+		boolean returnValue = false;
+		if (null !=  obj)
+		{
+			if (this == obj)
+			{
+				returnValue = true;
+			}
+			else
+			{
+				if (this.getClass() == obj.getClass())
+				{
+					CompositeObjectHandle<T> composite = (CompositeObjectHandle<T>)obj;
+					returnValue = new EqualsBuilder().appendSuper(super.equals(obj)).append(getHandle(), composite.getHandle()).isEquals();
+				}
+			}
+					
+		}
+		return returnValue;
+	}
+	@Override
+	public int hashCode() {
+		return new HashCodeBuilder(17, 37).append(getHandle()).toHashCode();
+	}
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/Mapping.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/Mapping.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/Mapping.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,6 @@
+package uk.ac.ncl.sdia.a8905943.spec;
+
+public interface Mapping {
+
+	public void getTransaction();
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/TransactionWorkspace.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/TransactionWorkspace.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/spec/TransactionWorkspace.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,10 @@
+package uk.ac.ncl.sdia.a8905943.spec;
+
+import uk.ac.ncl.sdia.a8905943.model.CompositeObjectHandle;
+
+public interface TransactionWorkspace {
+
+	public CompositeObjectHandle store(CompositeObjectHandle _object);
+	public CompositeObjectHandle find(long _handle);
+	
+}

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/util/HibernateUtil.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/util/HibernateUtil.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/java/uk/ac/ncl/sdia/a8905943/util/HibernateUtil.java	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,150 @@
+package uk.ac.ncl.sdia.a8905943.util;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+
+public class HibernateUtil {
+
+    public static final SessionFactory sessionFactory;
+
+    static {
+        try {
+            // Create the SessionFactory from hibernate.cfg.xml
+            sessionFactory = new Configuration().configure().buildSessionFactory();
+        } catch (Throwable ex) {
+            // Make sure you log the exception, as it might be swallowed
+            System.err.println("Initial SessionFactory creation failed." + ex);
+            throw new ExceptionInInitializerError(ex);
+        }
+    }
+
+    public static final ThreadLocal session = new ThreadLocal();
+
+    public static Session currentSession() throws HibernateException {
+        Session s = (Session) session.get();
+        // Open a new Session, if this thread has none yet
+        if (s == null) {
+            s = sessionFactory.openSession();
+            // Store it in the ThreadLocal variable
+            session.set(s);
+        }
+        return s;
+    }
+
+    public static void closeSession() throws HibernateException {
+        Session s = (Session) session.get();
+        if (s != null)
+            s.close();
+        session.set(null);
+    }
+    
+    static Connection conn; 
+    static Statement st;
+	public static void setup(String sql) {
+		try {
+			// Step 1: Load the JDBC driver.
+			Class.forName("org.hsqldb.jdbcDriver");
+			System.out.println("Driver Loaded.");
+			// Step 2: Establish the connection to the database.
+			String url = "jdbc:hsqldb:data/tutorial";
+
+			conn = DriverManager.getConnection(url, "sa", "");
+			System.out.println("Got Connection.");
+
+			st = conn.createStatement();
+			st.executeUpdate(sql);
+		} catch (Exception e) {
+			System.err.println("Got an exception! ");
+			e.printStackTrace();
+			System.exit(0);
+		}
+	}
+	public static void checkData(String sql) {
+		try {
+			HibernateUtil.outputResultSet(st
+					.executeQuery(sql));
+//			conn.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+    public static void outputResultSet(ResultSet rs) throws Exception{
+		ResultSetMetaData metadata = rs.getMetaData();
+
+		int numcols = metadata.getColumnCount();
+		String[] labels = new String[numcols]; 
+		int[] colwidths = new int[numcols];
+		int[] colpos = new int[numcols];
+		int linewidth;
+
+		linewidth = 1;
+		for (int i = 0; i < numcols; i++) {
+			colpos[i] = linewidth; 
+			labels[i] = metadata.getColumnLabel(i + 1); // get its label
+			int size = metadata.getColumnDisplaySize(i + 1);
+			if (size > 30 || size == -1)
+				size = 30;
+			int labelsize = labels[i].length();
+			if (labelsize > size)
+				size = labelsize;
+			colwidths[i] = size + 1; // save the column the size
+			linewidth += colwidths[i] + 2; // increment total size
+		}
+
+		StringBuffer divider = new StringBuffer(linewidth);
+		StringBuffer blankline = new StringBuffer(linewidth);
+		for (int i = 0; i < linewidth; i++) {
+			divider.insert(i, '-');
+			blankline.insert(i, " ");
+		}
+		// Put special marks in the divider line at the column positions
+		for (int i = 0; i < numcols; i++)
+			divider.setCharAt(colpos[i] - 1, '+');
+		divider.setCharAt(linewidth - 1, '+');
+
+		// Begin the table output with a divider line
+		System.out.println(divider);
+
+		// The next line of the table contains the column labels.
+		// Begin with a blank line, and put the column names and column
+		// divider characters "|" into it. overwrite() is defined below.
+		StringBuffer line = new StringBuffer(blankline.toString());
+		line.setCharAt(0, '|');
+		for (int i = 0; i < numcols; i++) {
+			int pos = colpos[i] + 1 + (colwidths[i] - labels[i].length()) / 2;
+			overwrite(line, pos, labels[i]);
+			overwrite(line, colpos[i] + colwidths[i], " |");
+		}
+		System.out.println(line);
+		System.out.println(divider);
+
+		while (rs.next()) {
+			line = new StringBuffer(blankline.toString());
+			line.setCharAt(0, '|');
+			for (int i = 0; i < numcols; i++) {
+				Object value = rs.getObject(i + 1);
+				overwrite(line, colpos[i] + 1, value.toString().trim());
+				overwrite(line, colpos[i] + colwidths[i], " |");
+			}
+			System.out.println(line);
+		}
+		System.out.println(divider);
+    	
+    }
+    
+	static void overwrite(StringBuffer b, int pos, String s) {
+		int len = s.length();
+		for (int i = 0; i < len; i++)
+			b.setCharAt(pos + i, s.charAt(i));
+	}
+    
+}
\ No newline at end of file

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/caveatemptor-beans.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/caveatemptor-beans.xml	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/caveatemptor-beans.xml	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+    xmlns="urn:jboss:bean-deployer:2.0">
+
+    <!-- Enable a JCA datasource available through JNDI -->
+    <bean name="caveatEmptorDatasourceFactory"
+          class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
+        <property name="jndiName">java:/caveatemptorTestingDatasource</property>
+
+        <!-- HSQL DB -->
+        <property name="driverClass">org.hsqldb.jdbcDriver</property>
+        <property name="connectionURL">jdbc:hsqldb:hsql://localhost</property>
+        <property name="userName">sa</property>
+
+        <property name="minSize">0</property>
+        <property name="maxSize">10</property>
+        <property name="blockingTimeout">1000</property>
+        <property name="idleTimeout">100000</property>
+
+        <property name="transactionManager"><inject bean="TransactionManager"/></property>
+        <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
+        <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
+    </bean>
+
+    <bean name="caveatemptorTestingDatasource" class="java.lang.Object">
+        <constructor factoryMethod="getDatasource">
+            <factory bean="caveatEmptorDatasourceFactory"/>
+        </constructor>
+    </bean>
+
+</deployment>


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/caveatemptor-beans.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/persistence.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/persistence.xml	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/persistence.xml	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,71 @@
+<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="caveatemptor">
+
+       <!-- A managed datasource provided by the application server, in this
+            case the microcontainer, see caveatemptor-beans.xml definition.
+        -->
+       <jta-data-source>java:/caveatemptorTestingDatasource</jta-data-source>
+
+       <!-- The path to scan for entity classes, different than the root of this file
+       <jar-file>file:/home/work/local/hibernate/jpwh/caveatemptor.jpa/build/classes</jar-file>
+        -->
+
+       <properties>
+          <!-- Only scan and detect annotated entities -->
+           <property name="hibernate.archive.autodetection" value="class"/>
+
+          <!-- Only scan and detect hbm.xml files
+          <property name="hibernate.archive.autodetection" value="hbm"/>
+          -->
+
+          <!-- SQL stdout logging
+           -->
+          <property name="hibernate.show_sql" value="false"/>
+          <property name="hibernate.format_sql" value="true"/>
+          <property name="use_sql_comments" value="true"/>
+
+           <!-- We have a JTA data source...
+          <property name="hibernate.connection.driver_class"
+                    value="org.hsqldb.jdbcDriver"/>
+          <property name="hibernate.connection.url"
+                    value="jdbc:hsqldb:hsql://localhost"/>
+          <property name="hibernate.connection.username"
+                    value="sa"/>
+
+          <property name="hibernate.c3p0.min_size"
+                    value="5"/>
+          <property name="hibernate.c3p0.max_size"
+                    value="20"/>
+          <property name="hibernate.c3p0.timeout"
+                    value="300"/>
+          <property name="hibernate.c3p0.max_statements"
+                    value="50"/>
+          <property name="hibernate.c3p0.idle_test_period"
+                    value="3000"/>
+           -->
+
+          <property name="hibernate.dialect"
+                    value="org.hibernate.dialect.HSQLDialect"/>
+
+           <!-- Put the EntityManagerFactory into JNDI so we can use it manually in tests -->
+           <property name="jboss.entity.manager.factory.jndi.name"
+                     value="java:/EntityManagerFactories/caveatEmptorEMF"/>
+
+           <!-- Create the database schema when this test.persistence unit is deployed, drop
+                it (clean the database) when it is undeployed
+           -->
+           <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+           
+           <!--  custom event listener for MVCC -->
+			<property name="hibernate.ejb.event.load" value="uk.ac.ncl.sdia.a8905943.event.MVCCLoadEventListener"/>
+		
+
+      </properties>
+   </persistence-unit>
+
+</persistence>
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/META-INF/persistence.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/basedata.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/basedata.xml	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/basedata.xml	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,168 @@
+<?xml version="1.0"?>
+
+<!--
+    Just a basic set of rows that are currently sufficient for all tests.
+    In future, maybe several datasets are required.
+-->
+<dataset>
+
+    <BILLING_DETAILS
+        BILLING_DETAILS_ID      ="1"
+        BILLING_DETAILS_TYPE    ="CC"
+        OBJ_VERSION             ="0"
+        OWNER                   ="John Doe"
+        CREATED                 ="2006-09-23 13:45:00"
+        USER_ID                 ="1"
+        BA_ACCOUNT              ="[NULL]"
+        BA_BANKNAME             ="[NULL]"
+        BA_SWIFT                ="[NULL]"
+    />
+
+    <CREDIT_CARD CREDIT_CARD_ID     ="1"
+                 CC_TYPE            ="MASTERCARD"
+                 CC_NUMBER          ="123123123123"
+                 CC_EXP_MONTH       ="08"
+                 CC_EXP_YEAR        ="2010"
+            />
+
+    <USERS
+        USER_ID             ="1"
+        OBJ_VERSION         ="0"
+        FIRSTNAME           ="John"
+        LASTNAME            ="Doe"
+        USERNAME            ="johndoe"
+        PASSWORD            ="secret"
+        EMAIL               ="jd at mail.tld"
+        RANK                ="0"
+        IS_ADMIN            ="true"
+        CREATED             ="2006-09-23 13:45:00"
+        HOME_STREET         ="Foostreet"
+        HOME_ZIPCODE        ="22222"
+        HOME_CITY           ="Foocity"
+        DEFAULT_BILLING_DETAILS_ID ="1"
+    />
+
+    <USERS
+        USER_ID             ="2"
+        OBJ_VERSION         ="0"
+        FIRSTNAME           ="Another"
+        LASTNAME            ="User"
+        USERNAME            ="anotheruser"
+        PASSWORD            ="secret"
+        EMAIL               ="anotheruser at mail.tld"
+        RANK                ="0"
+        IS_ADMIN            ="false"
+        CREATED             ="2006-09-23 13:45:00"
+        HOME_STREET         ="Foostreet"
+        HOME_ZIPCODE        ="22222"
+        HOME_CITY           ="Foocity"
+        DEFAULT_BILLING_DETAILS_ID ="[NULL]"
+    />
+
+    <ADDRESS
+        ADDRESS_ID      ="1"
+        OBJ_VERSION     ="0"
+        STREET          ="Shippingstreet 1"
+        ZIPCODE         ="12345"
+        CITY            ="Shippingcity"
+    />
+
+    <ITEM
+        ITEM_ID                 ="1"
+        OBJ_VERSION             ="0"
+        ITEM_NAME               ="Testitem 1"
+        DESCRIPTION             ="This is TestItem One."
+        INITIAL_PRICE           ="99"
+        INITIAL_PRICE_CURRENCY  ="USD"
+        RESERVE_PRICE           ="123"
+        RESERVE_PRICE_CURRENCY  ="USD"
+        START_DATE              ="2006-09-23 13:45:00"
+        END_DATE                ="2016-09-23 13:45:00"
+        ITEM_STATE              ="ACTIVE"
+        APPROVED_BY_USER_ID     ="1"
+        APPROVAL_DATETIME       ="2006-09-23 13:45:00"
+        SELLER_ID               ="1"
+        SUCCESSFUL_BID_ID       ="2"
+        CREATED                 ="2006-09-23 13:45:00"
+    />
+
+    <ITEM
+        ITEM_ID                 ="2"
+        OBJ_VERSION             ="0"
+        ITEM_NAME               ="Testitem 2"
+        DESCRIPTION             ="This is TestItem Two."
+        INITIAL_PRICE           ="111"
+        INITIAL_PRICE_CURRENCY  ="USD"
+        RESERVE_PRICE           ="222"
+        RESERVE_PRICE_CURRENCY  ="USD"
+        START_DATE              ="2006-09-23 13:45:00"
+        END_DATE                ="2016-09-23 13:45:00"
+        ITEM_STATE              ="DRAFT"
+        APPROVED_BY_USER_ID     ="1"
+        APPROVAL_DATETIME       ="2006-09-23 13:45:00"
+        SELLER_ID               ="1"
+        SUCCESSFUL_BID_ID       ="[NULL]"
+        CREATED                 ="2006-09-23 13:45:00"
+    />
+
+    <BID
+        BID_ID                  ="1"
+        BID_AMOUNT              ="100"
+        BID_AMOUNT_CURRENCY     ="USD"
+        ITEM_ID                 ="1"
+        BIDDER_ID               ="1"
+        BID_POSITION            ="0"
+        CREATED                 ="2006-09-23 13:46:00"
+    />
+
+    <BID
+        BID_ID                  ="2"
+        BID_AMOUNT              ="124"
+        BID_AMOUNT_CURRENCY     ="USD"
+        ITEM_ID                 ="1"
+        BIDDER_ID               ="1"
+        BID_POSITION            ="1"
+        CREATED                 ="2006-09-23 13:47:00"
+    />
+
+    <CATEGORY
+        CATEGORY_ID             ="1"
+        OBJ_VERSION             ="0"
+        CATEGORY_NAME           ="Category One"
+        CREATED                 ="2006-09-23 13:45:00"
+        PARENT_CATEGORY_ID      ="[NULL]"
+    />
+
+    <CATEGORY
+        CATEGORY_ID             ="2"
+        OBJ_VERSION             ="0"
+        CATEGORY_NAME           ="Category Two"
+        CREATED                 ="2006-09-23 13:45:00"
+        PARENT_CATEGORY_ID      ="1"
+    />
+
+    <CATEGORIZED_ITEM
+        CATEGORY_ID             ="1"
+        ITEM_ID                 ="1"
+        ADDED_BY_USER           ="johndoe"
+        ADDED_ON                ="2006-09-23 13:45:00"
+    />
+
+    <CATEGORIZED_ITEM
+        CATEGORY_ID             ="2"
+        ITEM_ID                 ="1"
+        ADDED_BY_USER           ="johndoe"
+        ADDED_ON                ="2006-09-23 13:45:00"
+    />
+
+    <COMMENT
+        COMMENT_ID              ="1"
+        OBJ_VERSION             ="0"
+        RATING                  ="OK"
+        COMMENT_TEXT            ="Just a comment."
+        ABOUT_ITEM_ID           ="1"
+        FROM_USER_ID            ="1"
+        CREATED                 ="2006-09-23 13:47:00"
+    />
+
+</dataset>


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/basedata.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/default.persistence.properties
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/default.persistence.properties	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/default.persistence.properties	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,2 @@
+hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
+hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/default.persistence.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/ejb3-interceptors-aop.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/ejb3-interceptors-aop.xml	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/ejb3-interceptors-aop.xml	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,360 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE aop PUBLIC
+   "-//JBoss//DTD JBOSS AOP 1.0//EN"
+   "http://www.jboss.org/aop/dtd/jboss-aop_1_0.dtd">
+
+<aop>
+   <interceptor class="org.jboss.aspects.remoting.InvokeRemoteInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.aspects.security.SecurityClientInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.aspects.tx.ClientTxPropagationInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.ejb3.remoting.IsLocalInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.aspects.remoting.ClusterChooserInterceptor" scope="PER_VM"/>
+
+   <interceptor class="org.jboss.aspects.tx.TxPropagationInterceptor" scope="PER_VM"/>
+
+   <stack name="ServiceClientInterceptors">
+      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+   </stack>
+
+   <stack name="AsynchronousStatelessSessionClientInterceptors">
+      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+   </stack>
+
+   <stack name="AsynchronousStatefulSessionClientInterceptors">
+      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+   </stack>
+
+   <stack name="StatelessSessionClientInterceptors">
+      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+   </stack>
+
+   <stack name="StatefulSessionClientInterceptors">
+      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+   </stack>
+
+   <stack name="ClusteredStatelessSessionClientInterceptors">
+      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+   </stack>
+
+   <stack name="ClusteredStatefulSessionClientInterceptors">
+      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+   </stack>
+
+   <interceptor class="org.jboss.ejb3.asynchronous.AsynchronousInterceptor" scope="PER_CLASS"/>
+   <interceptor class="org.jboss.ejb3.ENCPropagationInterceptor" scope="PER_VM"/>
+   <interceptor name="Basic Authorization" factory="org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorFactory" scope="PER_CLASS"/>
+   <interceptor name="JACC Authorization" factory="org.jboss.ejb3.security.JaccAuthorizationInterceptorFactory" scope="PER_CLASS"/>
+   <interceptor factory="org.jboss.ejb3.security.AuthenticationInterceptorFactory" scope="PER_CLASS"/>
+   <interceptor factory="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory" scope="PER_CLASS"/>
+   <interceptor class="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.ejb3.stateless.StatelessInstanceInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.ejb3.stateful.StatefulInstanceInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.ejb3.service.ServiceSingletonInterceptor" scope="PER_VM"/>
+   <interceptor class="org.jboss.ejb3.cache.StatefulReplicationInterceptor" scope="PER_VM"/>
+   <interceptor factory="org.jboss.ejb3.stateful.StatefulRemoveFactory" scope="PER_CLASS_JOINPOINT"/>
+   <interceptor factory="org.jboss.ejb3.tx.TxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
+   <interceptor factory="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory" scope="PER_CLASS_JOINPOINT"/>
+   <interceptor factory="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory" scope="PER_CLASS"/>
+   <interceptor class="org.jboss.ejb3.AllowedOperationsInterceptor" scope="PER_VM"/>
+   <interceptor factory="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory" scope="PER_CLASS"/>
+   <interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
+
+   <domain name="Stateless Bean">
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+         <interceptor-ref name="Basic Authorization"/>
+      </bind>
+      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+         <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+      </bind>
+      <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+         @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+      </annotation>
+   </domain>
+
+   <domain name="JACC Stateless Bean">
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+         <interceptor-ref name="JACC Authorization"/>
+      </bind>
+      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+         <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+      </bind>
+      <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+         @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+      </annotation>
+   </domain>
+
+   <domain name="Base Stateful Bean">
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+         <interceptor-ref name="Basic Authorization"/>
+      </bind>
+      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->@javax.ejb.Remove(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateful.StatefulRemoveFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateful.StatefulInstanceInterceptor"/>
+         <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+      </bind>
+      <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+      </bind>
+
+      <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..)) AND !execution(public * *->@javax.ejb.Remove(..))">
+         <interceptor-ref name="org.jboss.ejb3.cache.StatefulReplicationInterceptor"/>
+      </bind>
+      <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+         @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+      </annotation>
+   </domain>
+
+   <domain name="Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
+      <!-- NON Clustered cache configuration -->
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND !class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.simple.SimpleStatefulCache.class)
+      </annotation>
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.PersistenceManager) AND !class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.simple.PersistenceManager (org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.class)
+      </annotation>
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.CacheConfig) AND !class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.simple.CacheConfig (maxSize=100000, idleTimeoutSeconds=300)
+      </annotation>
+
+      <!-- Clustered cache configuration -->
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.tree.StatefulTreeCache.class)
+      </annotation>
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.tree.CacheConfig) AND class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.tree.CacheConfig (name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300)
+      </annotation>
+   </domain>
+
+   <domain name="JACC Stateful Bean">
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+         <interceptor-ref name="JACC Authorization"/>
+      </bind>
+      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->@javax.ejb.Remove(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateful.StatefulRemoveFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateful.StatefulInstanceInterceptor"/>
+         <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+      </bind>
+      <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+      </bind>
+
+      <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..)) AND !execution(public * *->@javax.ejb.Remove(..))">
+         <interceptor-ref name="org.jboss.ejb3.cache.StatefulReplicationInterceptor"/>
+      </bind>
+      <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+         @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+      </annotation>
+
+      <!-- NON Clustered cache configuration -->
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND !class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.simple.SimpleStatefulCache.class)
+      </annotation>
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.PersistenceManager) AND !class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.simple.PersistenceManager (org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.class)
+      </annotation>
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.CacheConfig) AND !class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.simple.CacheConfig (maxSize=100000, idleTimeoutSeconds=300)
+      </annotation>
+
+      <!-- Clustered cache configuration -->
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.tree.StatefulTreeCache.class)
+      </annotation>
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.tree.CacheConfig) AND class(@org.jboss.annotation.ejb.Clustered)">
+         @org.jboss.annotation.ejb.cache.tree.CacheConfig (name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300)
+      </annotation>
+   </domain>
+
+   <domain name="Embedded Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
+      <!-- NON Clustered cache configuration -->
+      <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache)">
+         @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.NoPassivationCache.class)
+      </annotation>
+
+   </domain>
+
+   <domain name="Message Driven Bean">
+      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+      </bind>
+      <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+         @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
+      </annotation>
+   </domain>
+   
+   <domain name="Consumer Bean">
+      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..)) AND (has(* *->@org.jboss.annotation.ejb.CurrentMessage(..)) OR hasfield(* *->@org.jboss.annotation.ejb.CurrentMessage))">
+         <interceptor-ref name="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+      </bind>
+      <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+         @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
+      </annotation>
+   </domain>
+
+   <domain name="Service Bean">
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+      </bind>
+      <bind pointcut="!execution(* *->create()) AND !execution(* *->start()) AND !execution(*->new(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+      </bind>      
+      <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+         <interceptor-ref name="Basic Authorization"/>
+      </bind>
+      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
+         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+      </bind>
+   </domain>
+
+   <domain name="JACC Service Bean">
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+      </bind>
+      <bind pointcut="!execution(* *->create()) AND !execution(* *->start()) AND !execution(*->new(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+      </bind>      
+      <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+         <interceptor-ref name="Basic Authorization"/>
+      </bind>
+      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+      </bind>
+      <bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
+         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+      </bind>
+   </domain>
+
+
+</aop>
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/ejb3-interceptors-aop.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/embedded-jboss-beans.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/embedded-jboss-beans.xml	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/embedded-jboss-beans.xml	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="Naming" class="org.jnp.server.SingletonNamingServer"/>
+
+   <bean name="InitialContextProperties" class="java.util.Hashtable">
+      <constructor>
+      <parameter class="java.util.Map">
+            <map keyClass="java.lang.String" valueClass="java.lang.String">
+               <entry>
+                  <key>java.naming.factory.initial</key>
+                  <value>org.jnp.interfaces.LocalOnlyContextFactory</value>
+               </entry>
+               <entry>
+                   <key>java.naming.factory.url.pkgs</key>
+                   <value>org.jboss.naming:org.jnp.interfaces</value>
+               </entry>
+            </map>
+      </parameter>
+      </constructor>
+   </bean>
+
+   <bean name="java:comp/Initializer" class="org.jboss.ejb3.embedded.JavaCompInitializer">
+      <property name="jndiProperties"><inject bean="InitialContextProperties"/></property>
+   </bean>
+
+   <bean name="XidFactory" class="org.jboss.tm.XidFactoryImpl"/>
+
+   <bean name="XidFactoryMBean" class="org.jboss.ejb3.embedded.XidFactoryMBean">
+      <constructor>
+         <parameter class="org.jboss.tm.XidFactoryBase">
+            <inject bean="XidFactory"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+   <bean name="TransactionManagerInitializer" class="org.jboss.tm.TransactionManagerInitializer">
+      <property name="xidFactory"><inject bean="XidFactory"/></property>
+      <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
+   </bean>
+
+   <bean name="UserTransaction" class="org.jboss.ejb3.embedded.UserTransactionImpl">
+      <demand>TransactionManagerInitializer</demand>
+   </bean>
+
+   <bean name="UserTransactionBinding" class="org.jboss.ejb3.embedded.JndiBinder">
+      <property name="jndiProperties"><inject bean="InitialContextProperties"/></property>
+      <property name="target"><inject bean="UserTransaction"/></property>
+      <property name="bindTo">UserTransaction</property>
+      <property name="serializable">false</property>
+   </bean>
+
+
+   <bean name="TransactionManager" class="java.lang.Object">
+      <constructor factoryMethod="getTransactionManager">
+         <factory bean="TransactionManagerInitializer"/>
+      </constructor>
+   </bean>
+   <bean name="CachedConnectionManager" class="org.jboss.resource.connectionmanager.CachedConnectionManagerReference">
+      <property name="transactionManager"><inject bean="TransactionManager"/></property>
+   </bean>
+
+   <!--
+      <bean class="org.jboss.jdbc.HypersonicDatabase"
+        name="jboss:service=Hypersonic,database=localDB">
+        <property name="database">localDB</property>
+        <property name="inProcessMode">true</property>
+        <property name="dbDataDir">.</property>
+      </bean>
+   -->
+<!--
+   <bean name="DefaultDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
+      <property name="driverClass">org.hsqldb.jdbcDriver</property>
+      <property name="connectionURL">jdbc:hsqldb:.</property>
+      <property name="userName">sa</property>
+      <property name="jndiName">java:/DefaultDS</property>
+      <property name="minSize">0</property>
+      <property name="maxSize">10</property>
+      <property name="blockingTimeout">1000</property>
+      <property name="idleTimeout">100000</property>
+      <property name="transactionManager"><inject bean="TransactionManager"/></property>
+      <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
+      <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
+   </bean>
+
+   <bean name="DefaultDS" class="java.lang.Object">
+      <constructor factoryMethod="getDatasource">
+         <factory bean="DefaultDSBootstrap"/>
+      </constructor>
+   </bean>
+-->
+    
+   <!--
+   <bean name="TimerServiceFactory" class="org.jboss.ejb3.timerservice.quartz.QuartzTimerServiceFactory">
+      <property name="properties">
+        	org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreCMT
+            org.quartz.jobStore.nonManagedTXDataSource=myDS
+            org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.HSQLDBDelegate
+            org.quartz.jobStore.tablePrefix=QRTZ_
+            org.quartz.jobStore.dataSource=myDS
+         
+	        # To get it to work with hypersonic
+	        # FIXME: this doesn't lock the row
+            org.quartz.jobStore.selectWithLockSQL=SELECT * FROM qrtz_locks WHERE lock_name = ?
+         
+        	# from quartz.properties
+            org.quartz.scheduler.instanceName=JBossEJB3QuartzScheduler
+            org.quartz.scheduler.rmi.export=false
+            org.quartz.scheduler.rmi.proxy=false
+            org.quartz.scheduler.wrapJobExecutionInUserTransaction=false
+   
+            org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
+            org.quartz.threadPool.threadCount=10
+            org.quartz.threadPool.threadPriority=5
+            org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true
+   
+        	org.quartz.jobStore.misfireThreshold=60000
+      </property>
+      <property name="dataSource">java:/DefaultDS</property>
+      <property name="sqlProperties">
+         CREATE_DB_ON_STARTUP = TRUE
+         
+         CREATE_TABLE_JOB_DETAILS = CREATE TABLE qrtz_job_details(JOB_NAME VARCHAR(80) NOT NULL, JOB_GROUP VARCHAR(80) NOT NULL, \
+            DESCRIPTION VARCHAR(120) NULL, JOB_CLASS_NAME VARCHAR(128) NOT NULL, IS_DURABLE VARCHAR(1) NOT NULL, \
+            IS_VOLATILE VARCHAR(1) NOT NULL, IS_STATEFUL VARCHAR(1) NOT NULL, REQUESTS_RECOVERY VARCHAR(1) NOT NULL, \
+            JOB_DATA BINARY NULL, PRIMARY KEY (JOB_NAME,JOB_GROUP))
+         CREATE_TABLE_JOB_LISTENERS = CREATE TABLE qrtz_job_listeners(JOB_NAME VARCHAR(80) NOT NULL, JOB_GROUP VARCHAR(80) NOT NULL, \
+            JOB_LISTENER VARCHAR(80) NOT NULL, PRIMARY KEY (JOB_NAME,JOB_GROUP,JOB_LISTENER), FOREIGN KEY (JOB_NAME,JOB_GROUP) \
+            REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP))
+         CREATE_TABLE_TRIGGERS = CREATE TABLE qrtz_triggers(TRIGGER_NAME VARCHAR(80) NOT NULL, TRIGGER_GROUP VARCHAR(80) NOT NULL, \
+            JOB_NAME VARCHAR(80) NOT NULL, JOB_GROUP VARCHAR(80) NOT NULL, IS_VOLATILE VARCHAR(1) NOT NULL, DESCRIPTION VARCHAR(120) NULL, \
+            NEXT_FIRE_TIME NUMERIC(13) NULL, PREV_FIRE_TIME NUMERIC(13) NULL, TRIGGER_STATE VARCHAR(16) NOT NULL, \
+            TRIGGER_TYPE VARCHAR(8) NOT NULL, START_TIME NUMERIC(13) NOT NULL, END_TIME NUMERIC(13) NULL, CALENDAR_NAME VARCHAR(80) NULL, \
+            MISFIRE_INSTR NUMERIC(2) NULL, JOB_DATA BINARY NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (JOB_NAME,JOB_GROUP) \
+            REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP))
+         CREATE_TABLE_SIMPLE_TRIGGERS = CREATE TABLE qrtz_simple_triggers(TRIGGER_NAME VARCHAR(80) NOT NULL, \
+            TRIGGER_GROUP VARCHAR(80) NOT NULL, REPEAT_COUNT NUMERIC(7) NOT NULL, REPEAT_INTERVAL NUMERIC(12) NOT NULL, \
+            TIMES_TRIGGERED NUMERIC(7) NOT NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) \
+            REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP))
+         CREATE_TABLE_CRON_TRIGGERS = CREATE TABLE qrtz_cron_triggers(TRIGGER_NAME VARCHAR(80) NOT NULL, \
+            TRIGGER_GROUP VARCHAR(80) NOT NULL, CRON_EXPRESSION VARCHAR(80) NOT NULL, TIME_ZONE_ID VARCHAR(80), \
+            PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) \
+            REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP))
+         CREATE_TABLE_BLOB_TRIGGERS = CREATE TABLE qrtz_blob_triggers(TRIGGER_NAME VARCHAR(80) NOT NULL, \
+            TRIGGER_GROUP VARCHAR(80) NOT NULL, BLOB_DATA BINARY NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), \
+            FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP))
+         CREATE_TABLE_TRIGGER_LISTENERS = CREATE TABLE qrtz_trigger_listeners(TRIGGER_NAME VARCHAR(80) NOT NULL, \
+            TRIGGER_GROUP VARCHAR(80) NOT NULL, TRIGGER_LISTENER VARCHAR(80) NOT NULL, \
+            PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_LISTENER), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) \
+            REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP))
+         CREATE_TABLE_CALENDARS = CREATE TABLE qrtz_calendars(CALENDAR_NAME VARCHAR(80) NOT NULL, CALENDAR BINARY NOT NULL, \
+            PRIMARY KEY (CALENDAR_NAME))
+         CREATE_TABLE_PAUSED_TRIGGER_GRPS = CREATE TABLE qrtz_paused_trigger_grps(TRIGGER_GROUP VARCHAR(80) NOT NULL, \
+            PRIMARY KEY (TRIGGER_GROUP))
+         CREATE_TABLE_FIRED_TRIGGERS = CREATE TABLE qrtz_fired_triggers(ENTRY_ID VARCHAR(95) NOT NULL, TRIGGER_NAME VARCHAR(80) NOT NULL, \
+            TRIGGER_GROUP VARCHAR(80) NOT NULL, IS_VOLATILE VARCHAR(1) NOT NULL, INSTANCE_NAME VARCHAR(80) NOT NULL, \
+            FIRED_TIME NUMERIC(13) NOT NULL, STATE VARCHAR(16) NOT NULL, JOB_NAME VARCHAR(80) NULL, JOB_GROUP VARCHAR(80) NULL, \
+            IS_STATEFUL VARCHAR(1) NULL, REQUESTS_RECOVERY VARCHAR(1) NULL, PRIMARY KEY (ENTRY_ID))
+         CREATE_TABLE_SCHEDULER_STATE = CREATE TABLE qrtz_scheduler_state(INSTANCE_NAME VARCHAR(80) NOT NULL, \
+            LAST_CHECKIN_TIME NUMERIC(13) NOT NULL, CHECKIN_INTERVAL NUMERIC(13) NOT NULL, RECOVERER VARCHAR(80) NULL, \
+            PRIMARY KEY (INSTANCE_NAME))
+         CREATE_TABLE_LOCKS = CREATE TABLE qrtz_locks(LOCK_NAME VARCHAR(40) NOT NULL, PRIMARY KEY (LOCK_NAME))
+         INSERT_TRIGGER_ACCESS = INSERT INTO qrtz_locks values('TRIGGER_ACCESS')
+         INSERT_JOB_ACCESS = INSERT INTO qrtz_locks values('JOB_ACCESS')
+         INSERT_CALENDAR_ACCESS = INSERT INTO qrtz_locks values('CALENDAR_ACCESS')
+         INSERT_STATE_ACCESS = INSERT INTO qrtz_locks values('STATE_ACCESS')
+         INSERT_MISFIRE_ACCESS = INSERT INTO qrtz_locks values('MISFIRE_ACCESS')
+      </property>
+   </bean>
+
+   -->
+   
+</deployment>
\ No newline at end of file


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/embedded-jboss-beans.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/jndi.properties
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/jndi.properties	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/jndi.properties	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,2 @@
+java.naming.factory.initial org.jnp.interfaces.LocalOnlyContextFactory
+java.naming.factory.url.pkgs org.jboss.naming:org.jnp.interfaces


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/jndi.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/log4j.properties
===================================================================
--- labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/log4j.properties	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/log4j.properties	2009-04-20 17:01:38 UTC (rev 26158)
@@ -0,0 +1,21 @@
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{6}:%L - %m%n
+
+# Root logger option
+log4j.rootLogger=ERROR, stdout
+
+# Hibernate logging options (INFO only shows startup messages)
+#log4j.logger.org.hibernate=DEBUG
+
+# Log JDBC bind parameter runtime arguments
+#log4j.logger.org.hibernate.type=DEBUG
+
+# JBoss EJB 3.0 container logging
+#log4j.logger.org.jboss=DEBUG
+
+# Disable warnings of noisy classes
+log4j.logger.org.jboss.ejb3.timerservice.jboss.JBossTimerServiceFactory=ERROR
+log4j.logger.org.hibernate.ejb.Ejb3Configuration=ERROR


Property changes on: labs/jbosstm/workspace/whitingjr/HibernateWithInMemoryObjects/src/main/resources/log4j.properties
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-svn-commits mailing list