[jboss-cvs] JBossAS SVN: r60448 - in branches/Branch_4_2/ejb3/src: test/org/jboss/ejb3/test/timestampentity and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 8 19:23:02 EST 2007


Author: bdecoste
Date: 2007-02-08 19:23:02 -0500 (Thu, 08 Feb 2007)
New Revision: 60448

Added:
   branches/Branch_4_2/ejb3/src/resources/test/timestampentity/META-INF/persistence.xml
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManager.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerCommon.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerConstants.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerLocal.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1IntegerEntity.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1Key.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1TimestampEntity.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/unit/EntityUnitTestCase.java
Log:
test for closing resources for Entity with timestamp field

Added: branches/Branch_4_2/ejb3/src/resources/test/timestampentity/META-INF/persistence.xml
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test/timestampentity/META-INF/persistence.xml	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/resources/test/timestampentity/META-INF/persistence.xml	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence>
+   <persistence-unit name="tempdb">
+      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <properties>
+          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+      </properties>
+   </persistence-unit>
+</persistence>

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManager.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManager.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManager.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,25 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion Proprietary. Do not reproduce without permission in writing.
+**         Copyright (c) 2006 Research In Motion Limited
+**                 All rights reserved
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity;
+import javax.ejb.Remote;
+
+/***********************************************************************************************************************************
+**
+** Defines the Locale String Manager session bean remote interface.
+** <p>
+**
+** @author  Jonathan Grills
+** @version $Id: LocaleStringManager.java
+**
+************************************************************************************************************************************
+*/
+ at Remote
+public interface TestManager extends TestManagerCommon {
+
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerBean.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerBean.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,224 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion Proprietary. Do not reproduce without permission in writing.
+**         Copyright (c) 2006 Research In Motion Limited
+**                 All rights reserved
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity;
+
+import javax.ejb.Stateless;
+import javax.persistence.PersistenceContext;
+import javax.persistence.EntityManager;
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.annotation.security.SecurityDomain;
+import org.jboss.ejb3.test.timestampentity.entity.Table1IntegerEntity;
+import org.jboss.ejb3.test.timestampentity.entity.Table1Key;
+import org.jboss.ejb3.test.timestampentity.entity.Table1TimestampEntity;
+import java.util.Date;
+
+/***********************************************************************************************************************************
+**
+** Implements the Test Manager session bean.
+** <p>
+**
+** @author  Jonathan Grills
+** @version $Id: TestManagerBean.java
+**
+************************************************************************************************************************************
+*/
+ at Stateless
+//@RemoteBinding(clientBindUrl="sslsocket://0.0.0.0:3843", jndiBinding=TestManagerConstants.JNDI_BINDING)
+ at RemoteBinding(jndiBinding=TestManagerConstants.JNDI_BINDING)
+//@SecurityDomain("bas")
+public class TestManagerBean implements TestManager, TestManagerLocal {
+
+/***********************************************************************************************************************************
+**
+** EntityManager.
+**
+************************************************************************************************************************************
+*/
+  @PersistenceContext EntityManager _entityManager;
+
+/***********************************************************************************************************************************
+**
+** @see TestManagerCommon#findTestInteger(String, int, String)
+**
+************************************************************************************************************************************
+*/
+  public boolean findTestInteger (String keyField1, int keyField2, String keyField3) {
+
+    final String METHOD_NAME = "findTestInteger";
+    System.out.println(METHOD_NAME + ": Enter.");
+    Table1Key table1Id = new Table1Key(keyField1, keyField2, keyField3);
+    boolean isRecordFound = false;
+    try {
+      Table1IntegerEntity queryResult = _entityManager.find(Table1IntegerEntity.class, table1Id);
+      isRecordFound = queryResult.equals(null);
+    }
+    catch (Exception e) {
+      System.out.println(e.toString());
+    }
+    System.out.println(METHOD_NAME + ": Enter.");
+    return isRecordFound;
+  }
+
+/***********************************************************************************************************************************
+**
+** @see TestManagerCommon#findTestTimestamp(String, int, String)
+**
+************************************************************************************************************************************
+*/
+  public boolean findTestTimestamp (String keyField1, int keyField2, String keyField3) {
+
+    final String METHOD_NAME = "findTestTimestamp";
+    System.out.println(METHOD_NAME + ": Enter.");
+    Table1Key table1Id = new Table1Key(keyField1, keyField2, keyField3);
+    boolean isRecordFound = false;
+    try {
+      Table1TimestampEntity queryResult = _entityManager.find(Table1TimestampEntity.class, table1Id);
+      isRecordFound = queryResult.equals(null);
+    }
+    catch (Exception e) {
+      System.out.println(e.toString());
+    }
+    System.out.println(METHOD_NAME + ": Enter.");
+    return isRecordFound;
+  }
+
+/***********************************************************************************************************************************
+**
+** Create a table1IntegerEntity object
+**
+** @param      keyField1   the table1IntegerEntity object
+** @param      keyField2   the table1IntegerEntity object
+** @param      keyField3   the table1IntegerEntity object
+** @param      field1   the table1IntegerEntity object
+** @param      field2   the table1IntegerEntity object
+** @param      field3   the table1IntegerEntity object
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  public Table1Key createTestInteger (
+  String keyField1, int keyField2, String keyField3, String field1, String field2, Date field3) {
+
+    final String METHOD_NAME = "createTestInteger";
+    System.out.println(METHOD_NAME + ": Enter.");
+    Table1Key table1Key = new Table1Key(keyField1, keyField2, keyField3);
+    Table1IntegerEntity table1Integer = new Table1IntegerEntity();
+    table1Integer.setId(table1Key);
+    table1Integer.setField1(field1);
+    table1Integer.setField2(field2);
+    table1Integer.setField3(field3);
+    _entityManager.persist(table1Integer);
+    System.out.println(METHOD_NAME + ": Exit.");
+    return table1Key;
+  }
+
+/***********************************************************************************************************************************
+**
+** Updates a table1IntegerEntity object
+**
+** @param      keyField1   the table1IntegerEntity object
+** @param      keyField2   the table1IntegerEntity object
+** @param      keyField3   the table1IntegerEntity object
+** @param      field1   the table1IntegerEntity object
+** @param      field2   the table1IntegerEntity object
+** @param      field3   the table1IntegerEntity object
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  public Table1Key updateTestInteger (
+  String keyField1, int keyField2, String keyField3, String field1, String field2, Date field3) {
+
+    final String METHOD_NAME = "updateTestInteger";
+    System.out.println(METHOD_NAME + ": Enter.");
+    Table1IntegerEntity table1Integer;
+    Table1Key table1Key = new Table1Key(keyField1, keyField2, keyField3);
+    try {
+      table1Integer = _entityManager.find(Table1IntegerEntity.class, table1Key);
+      table1Integer.setField1(field1);
+      table1Integer.setField2(field2);
+      table1Integer.setField3(field3);
+      _entityManager.merge(table1Integer);
+    }
+    catch (Exception e) {
+      System.out.println(e.toString());
+    }
+    System.out.println(METHOD_NAME + ": Exit.");
+    return table1Key;
+  }
+
+/***********************************************************************************************************************************
+**
+** Create a table1TimestampEntity object
+**
+** @param      keyField1   the table1IntegerEntity object
+** @param      keyField2   the table1IntegerEntity object
+** @param      keyField3   the table1IntegerEntity object
+** @param      field1   the table1IntegerEntity object
+** @param      field2   the table1IntegerEntity object
+** @param      field3   the table1IntegerEntity object
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  public Table1Key createTestTimestamp (
+  String keyField1, int keyField2, String keyField3, String field1, String field2, Date field3) {
+
+    final String METHOD_NAME = "createTestTimestamp";
+    System.out.println(METHOD_NAME + ": Enter.");
+    Table1Key table1Key = new Table1Key(keyField1, keyField2, keyField3);
+    Table1TimestampEntity table1Timestamp = new Table1TimestampEntity();
+    table1Timestamp.setId(table1Key);
+    table1Timestamp.setField1(field1);
+    table1Timestamp.setField2(field2);
+    table1Timestamp.setField3(field3);
+    _entityManager.persist(table1Timestamp);
+    System.out.println(METHOD_NAME + ": Exit.");
+    return table1Key;
+  }
+
+/***********************************************************************************************************************************
+**
+** Updates a table1TimestampEntity object
+**
+** @param      keyField1   the table1IntegerEntity object
+** @param      keyField2   the table1IntegerEntity object
+** @param      keyField3   the table1IntegerEntity object
+** @param      field1   the table1IntegerEntity object
+** @param      field2   the table1IntegerEntity object
+** @param      field3   the table1IntegerEntity object
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  public Table1Key updateTestTimestamp (
+  String keyField1, int keyField2, String keyField3, String field1, String field2, Date field3) {
+
+    final String METHOD_NAME = "updateTestTimestamp";
+    System.out.println(METHOD_NAME + ": Enter.");
+    Table1TimestampEntity table1Timestamp;
+    Table1Key table1Key = new Table1Key(keyField1, keyField2, keyField3);
+    try {
+      table1Timestamp = _entityManager.find(Table1TimestampEntity.class, table1Key);
+      table1Timestamp.setField1(field1);
+      table1Timestamp.setField2(field2);
+      table1Timestamp.setField3(field3);
+      _entityManager.merge(table1Timestamp);
+    }
+    catch (Exception e) {
+      System.out.println(e.toString());
+    }
+    System.out.println(METHOD_NAME + ": Exit.");
+    return table1Key;
+  }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerCommon.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerCommon.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerCommon.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,92 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion Proprietary. Do not reproduce without permission in writing.
+**         Copyright (c) 2006 Research In Motion Limited
+**                 All rights reserved
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity;
+
+import org.jboss.ejb3.test.timestampentity.entity.Table1Key;
+
+import java.util.Date;
+
+/***********************************************************************************************************************************
+**
+** Defines the Test Manager session bean interface.
+** <p>
+**
+** @author  Jonathan Grills
+** @version $Id: TestManagerCommon.java
+**
+************************************************************************************************************************************
+*/
+public interface TestManagerCommon {
+
+/***********************************************************************************************************************************
+**
+** Method to return a specific table1Integer record.
+**
+** @param      field1   the field1
+** @param      field2   the field2
+** @param      field3   the field3
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  public boolean findTestInteger (String field1, int field2, String field3);
+
+/***********************************************************************************************************************************
+**
+** Method to return a specific table1Timestamp record.
+**
+** @param      field1   the field1
+** @param      field2   the field2
+** @param      field3   the field3
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  public boolean findTestTimestamp (String field1, int field2, String field3);
+
+/***********************************************************************************************************************************
+**
+** Create a table1IntegerEntity object
+**
+** @param      keyField1   the table1IntegerEntity object
+** @param      keyField2   the table1IntegerEntity object
+** @param      keyField3   the table1IntegerEntity object
+** @param      field1   the table1IntegerEntity object
+** @param      field2   the table1IntegerEntity object
+** @param      field3   the table1IntegerEntity object
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  public Table1Key createTestInteger (String keyField1, int keyField2, String keyField3, String field1, String field2, Date field3);
+  public Table1Key updateTestInteger (String keyField1, int keyField2, String keyField3, String field1, String field2, Date field3);
+
+/***********************************************************************************************************************************
+**
+** Create a table1TimestampEntity object
+**
+** @param      keyField1   the table1IntegerEntity object
+** @param      keyField2   the table1IntegerEntity object
+** @param      keyField3   the table1IntegerEntity object
+** @param      field1   the table1IntegerEntity object
+** @param      field2   the table1IntegerEntity object
+** @param      field3   the table1IntegerEntity object
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  public Table1Key createTestTimestamp (
+  String keyField1, int keyField2, String keyField3, String field1, String field2, Date field3);
+  public Table1Key updateTestTimestamp (
+  String keyField1, int keyField2, String keyField3, String field1, String field2, Date field3);
+}
\ No newline at end of file

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerConstants.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerConstants.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerConstants.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,29 @@
+/***********************************************************************************************************************************
+**
+** Research in Motion. Do not reproduce without permission in writing.
+** Copyright (c) 2006 Research In Motion.
+** All rights reserved.
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity;
+
+/***********************************************************************************************************************************
+**
+** This class defines constants for this package.
+**
+** @author    K. Schneider
+** @version   $Id$
+**
+************************************************************************************************************************************
+*/
+public class TestManagerConstants {
+
+/***********************************************************************************************************************************
+**
+** The JNDI binding.
+**
+************************************************************************************************************************************
+*/
+  public static final String JNDI_BINDING = "ejb/bms/testmanager/TestManager";
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerLocal.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerLocal.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/TestManagerLocal.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,25 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion Proprietary. Do not reproduce without permission in writing.
+**         Copyright (c) 2006 Research In Motion Limited
+**                 All rights reserved
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity;
+import javax.ejb.Local;
+
+/***********************************************************************************************************************************
+**
+** Defines the Test Manager Session bean local interface
+** <p>
+**
+** @author  Jonathan Grills
+** @version $Id: TestManagerLocal.java
+**
+************************************************************************************************************************************
+*/
+ at Local
+public interface TestManagerLocal extends TestManagerCommon {
+
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1IntegerEntity.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1IntegerEntity.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1IntegerEntity.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,257 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion.  Do not reproduce without permission in writing.
+**
+** Copyright (c) 2006 Research In Motion.
+** All rights reserved.
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity.entity;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Version;
+import java.util.Date;
+
+/***********************************************************************************************************************************
+**
+** This is a entity bean primary key class for the BASAuthenticationCredentials table...Generated 4-Jan-2007 2:58:35 PM
+** by Hibernate Tools 3.2.0.beta7
+**
+** @author     jgrills
+** @version    T.B.D
+**
+************************************************************************************************************************************
+*/
+ at Entity
+ at Table(name = "Table1Integer")
+public class Table1IntegerEntity implements java.io.Serializable {
+
+/***********************************************************************************************************************************
+**
+** The primary key class
+**
+************************************************************************************************************************************
+*/
+  private Table1Key _table1Key;
+
+/***********************************************************************************************************************************
+**
+** The field1 attribute
+**
+************************************************************************************************************************************
+*/
+  private String _field1;
+
+/***********************************************************************************************************************************
+**
+** The fiedl2 attribute
+**
+************************************************************************************************************************************
+*/
+  private String _field2;
+
+/***********************************************************************************************************************************
+**
+** The field3 attribute
+**
+************************************************************************************************************************************
+*/
+  private Date _field3;
+
+/***********************************************************************************************************************************
+**
+** The versionNumber attribute
+**
+************************************************************************************************************************************
+*/
+  private int _versionNumber;
+
+/***********************************************************************************************************************************
+**
+** The default constructor for an Table1IntegerEntity
+**
+************************************************************************************************************************************
+*/
+  public Table1IntegerEntity () {
+
+  }
+
+/***********************************************************************************************************************************
+**
+** The minimal constructor for an Table1IntegerEntity
+**
+** @param      table1Key   the primary key class
+** @param      field1   the field1
+** @param      field2   the field2
+**
+************************************************************************************************************************************
+*/
+  public Table1IntegerEntity (Table1Key table1Key, String field1, String field2) {
+
+    _table1Key = table1Key;
+    _field1 = field1;
+    _field2 = field2;
+  }
+
+/***********************************************************************************************************************************
+**
+** The full constructor for an Table1IntegerEntity
+**
+** @param      table1Key   the primary key class
+** @param      field1   the field1
+** @param      field2   the field2
+** @param      field3   the field3
+**
+************************************************************************************************************************************
+*/
+  public Table1IntegerEntity (Table1Key table1Key, String field1, String field2, Date field3) {
+
+    _table1Key = table1Key;
+    _field1 = field1;
+    _field2 = field2;
+    _field3 = field3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the primary key class
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  @EmbeddedId
+  @AttributeOverrides({
+    @AttributeOverride(name = "keyfield1", column = @Column(name = "Keyfield1")),
+    @AttributeOverride(name = "keyfield2", column = @Column(name = "Keyfield2")),
+    @AttributeOverride(name = "keyfield3", column = @Column(name = "Keyfield3"))
+  })
+  public Table1Key getId () {
+
+    return _table1Key;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the primary key class
+**
+** @param      table1Key   the primary key class
+**
+************************************************************************************************************************************
+*/
+  public void setId (Table1Key table1Key) {
+
+    _table1Key = table1Key;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field1
+**
+** @return     the field1
+**
+************************************************************************************************************************************
+*/
+  public String getField1 () {
+
+    return _field1;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field1
+**
+** @param      field1   the field1
+**
+************************************************************************************************************************************
+*/
+  public void setField1 (String field1) {
+
+    _field1 = field1;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field2
+**
+** @return     the field2
+**
+************************************************************************************************************************************
+*/
+  public String getField2 () {
+
+    return _field2;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field2
+**
+** @param      field2   the field2
+**
+************************************************************************************************************************************
+*/
+  public void setField2 (String field2) {
+
+    _field2 = field2;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field3
+**
+** @return     the field3
+**
+************************************************************************************************************************************
+*/
+  public Date getField3 () {
+
+    return _field3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field3
+**
+** @param      field3   the field3
+**
+************************************************************************************************************************************
+*/
+  public void setField3 (Date field3) {
+
+    _field3 = field3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the lurnum attribute
+**
+** @return     the lurnum attribute
+**
+************************************************************************************************************************************
+*/
+  @Version
+  public int getVersionNumber () {
+
+   return _versionNumber;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the versionNumber attribute
+**
+** @param      versionNumber   the versionNumber attribute
+**
+************************************************************************************************************************************
+*/
+  public void setVersionNumber (int versionNumber) {
+
+    _versionNumber = versionNumber;
+  }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1Key.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1Key.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1Key.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,194 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion.  Do not reproduce without permission in writing.
+**
+** Copyright (c) 2006 Research In Motion.
+** All rights reserved.
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity.entity;
+
+import javax.persistence.Embeddable;
+
+/***********************************************************************************************************************************
+**
+** This is a primary key class for the BMSTable1 table...Generated 27-Nov-2006 9:48:27 AM by Hibernate Tools 3.2.0.beta7
+**
+** @author     jgrills
+** @version    T.B.D
+**
+************************************************************************************************************************************
+*/
+ at Embeddable
+public class Table1Key implements java.io.Serializable {
+
+/***********************************************************************************************************************************
+**
+** The locale identifer
+**
+************************************************************************************************************************************
+*/
+  private String _keyField1;
+
+/***********************************************************************************************************************************
+**
+** The plugin identifier
+**
+************************************************************************************************************************************
+*/
+  private int _keyField2;
+
+/***********************************************************************************************************************************
+**
+** The string identifier
+**
+************************************************************************************************************************************
+*/
+  private String _keyField3;
+
+/***********************************************************************************************************************************
+**
+** The default constructor for a Table1 primary key
+**
+************************************************************************************************************************************
+*/
+  public Table1Key () {
+
+  }
+
+/***********************************************************************************************************************************
+**
+** The full constructor for a Table1 primary key
+**
+** @param      keyField1   the localeIdentifier
+** @param      keyField2   the localeIdentifier
+** @param      keyField3   the localeIdentifier
+**
+************************************************************************************************************************************
+*/
+  public Table1Key (String keyField1, int keyField2, String keyField3) {
+
+    _keyField1 = keyField1;
+    _keyField2 = keyField2;
+    _keyField3 = keyField3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the keyField1 identifier
+**
+** @return     the keyField1 identifier
+**
+************************************************************************************************************************************
+*/
+  public String getKeyField1 () {
+
+    return _keyField1;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the keyField1 identifier
+**
+** @param      keyField1   the keyField1 identifier
+**
+************************************************************************************************************************************
+*/
+  public void setKeyField1 (String keyField1) {
+
+    _keyField1 = keyField1;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the keyField2 identifier
+**
+** @return     the keyField2 identifier
+**
+************************************************************************************************************************************
+*/
+  public int getKeyField2 () {
+
+    return _keyField2;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the keyField2 identifier
+**
+** @param      keyField2   the keyField2 identifier
+**
+************************************************************************************************************************************
+*/
+  public void setKeyField2 (int keyField2) {
+
+    _keyField2 = keyField2;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the keyField3 identifier
+**
+** @return     the keyField3 identifier
+**
+************************************************************************************************************************************
+*/
+  public String getKeyField3 () {
+
+    return _keyField3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the keyField3 identifier
+**
+** @param      keyField3   the keyField3 identifier
+**
+************************************************************************************************************************************
+*/
+  public void setKeyField3 (String keyField3) {
+
+    _keyField3 = keyField3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The primary key class' equals method
+**
+** @param      other   a comparison object
+**
+************************************************************************************************************************************
+*/
+  public boolean equals (Object other) {
+
+    if ((this == other))
+    return true;
+    if ((other == null))
+    return false;
+    if (!(other instanceof Table1Key))
+    return false;
+    Table1Key castOther = (Table1Key) other;
+
+    return ((this.getKeyField1() == castOther.getKeyField1()) || (this.getKeyField1() != null && castOther.getKeyField1() != null
+    && this.getKeyField1().equals(castOther.getKeyField1()))) && (this.getKeyField2() == castOther.getKeyField2())
+    && ((this.getKeyField3() == castOther.getKeyField3()) || (this.getKeyField3() != null && castOther.getKeyField3() != null
+    && this.getKeyField3().equals(castOther.getKeyField3())));
+  }
+
+/***********************************************************************************************************************************
+**
+** The primary key class' hashCode method
+**
+************************************************************************************************************************************
+*/
+  public int hashCode () {
+
+    int result = 17;
+
+    result = 37 * result + (getKeyField1() == null ? 0 : this.getKeyField1().hashCode());
+    result = 37 * result + this.getKeyField2();
+    result = 37 * result+ (getKeyField3() == null ? 0 : this.getKeyField3().hashCode());
+    return result;
+  }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1TimestampEntity.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1TimestampEntity.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1TimestampEntity.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,261 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion.  Do not reproduce without permission in writing.
+**
+** Copyright (c) 2006 Research In Motion.
+** All rights reserved.
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity.entity;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Version;
+import java.util.Date;
+import org.hibernate.annotations.Generated;
+import org.hibernate.annotations.GenerationTime;
+
+/***********************************************************************************************************************************
+**
+** This is a entity bean primary key class for the Table1 table...Generated 4-Jan-2007 2:58:35 PM
+** by Hibernate Tools 3.2.0.beta7
+**
+** @author     jgrills
+** @version    T.B.D
+**
+************************************************************************************************************************************
+*/
+ at Entity
+ at Table(name = "Table1Timestamp")
+public class Table1TimestampEntity implements java.io.Serializable {
+
+/***********************************************************************************************************************************
+**
+** The primary key class
+**
+************************************************************************************************************************************
+*/
+  private Table1Key _table1Key;
+
+/***********************************************************************************************************************************
+**
+** The field1 attribute
+**
+************************************************************************************************************************************
+*/
+  private String _field1;
+
+/***********************************************************************************************************************************
+**
+** The fiedl2 attribute
+**
+************************************************************************************************************************************
+*/
+  private String _field2;
+
+/***********************************************************************************************************************************
+**
+** The field3 attribute
+**
+************************************************************************************************************************************
+*/
+  private Date _field3;
+
+/***********************************************************************************************************************************
+**
+** The lurnum attribute
+**
+************************************************************************************************************************************
+*/
+  private byte[] _lurnum;
+
+/***********************************************************************************************************************************
+**
+** The default constructor for an Table1TimestampEntity
+**
+************************************************************************************************************************************
+*/
+  public Table1TimestampEntity () {
+
+  }
+
+/***********************************************************************************************************************************
+**
+** The minimal constructor for an Table1TimestampEntity
+**
+** @param      table1Key   the primary key class
+** @param      field1   the field1
+** @param      field2   the field2
+**
+************************************************************************************************************************************
+*/
+  public Table1TimestampEntity (Table1Key table1Key, String field1, String field2) {
+
+    _table1Key = table1Key;
+    _field1 = field1;
+    _field2 = field2;
+  }
+
+/***********************************************************************************************************************************
+**
+** The full constructor for an Table1TimestampEntity
+**
+** @param      table1Key   the primary key class
+** @param      field1   the field1
+** @param      field2   the field2
+** @param      field3   the field3
+**
+************************************************************************************************************************************
+*/
+  public Table1TimestampEntity (Table1Key table1Key, String field1, String field2, Date field3) {
+
+    _table1Key = table1Key;
+    _field1 = field1;
+    _field2 = field2;
+    _field3 = field3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the primary key class
+**
+** @return     the primary key
+**
+************************************************************************************************************************************
+*/
+  @EmbeddedId
+  @AttributeOverrides({
+    @AttributeOverride(name = "keyfield1", column = @Column(name = "Keyfield1")),
+    @AttributeOverride(name = "keyfield2", column = @Column(name = "Keyfield2")),
+    @AttributeOverride(name = "keyfield3", column = @Column(name = "Keyfield3"))
+  })
+  public Table1Key getId () {
+
+    return _table1Key;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the primary key class
+**
+** @param      table1Key   the primary key class
+**
+************************************************************************************************************************************
+*/
+  public void setId (Table1Key table1Key) {
+
+    _table1Key = table1Key;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field1
+**
+** @return     the field1
+**
+************************************************************************************************************************************
+*/
+  public String getField1 () {
+
+    return _field1;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field1
+**
+** @param      field1   the field1
+**
+************************************************************************************************************************************
+*/
+  public void setField1 (String field1) {
+
+    _field1 = field1;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field2
+**
+** @return     the field2
+**
+************************************************************************************************************************************
+*/
+  public String getField2 () {
+
+    return _field2;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field2
+**
+** @param      field2   the field2
+**
+************************************************************************************************************************************
+*/
+  public void setField2 (String field2) {
+
+    _field2 = field2;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field3
+**
+** @return     the field3
+**
+************************************************************************************************************************************
+*/
+  public Date getField3 () {
+
+    return _field3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field3
+**
+** @param      field3   the field3
+**
+************************************************************************************************************************************
+*/
+  public void setField3 (Date field3) {
+
+    _field3 = field3;
+  }
+
+/***********************************************************************************************************************************
+**
+** The get method for the lurnum attribute
+**
+** @return     the lurnum attribute
+**
+************************************************************************************************************************************
+*/
+  @Version
+  @Generated(GenerationTime.ALWAYS)
+  @Column(insertable = false, updatable = false, columnDefinition="TIMESTAMP")
+  public byte[] getLurnum () {
+
+   return _lurnum;
+  }
+
+/***********************************************************************************************************************************
+**
+** The set method for the lurnum attribute
+**
+** @param      lurnum   the lurnum attribute
+**
+************************************************************************************************************************************
+*/
+  public void setLurnum (byte[] lurnum) {
+
+   _lurnum = lurnum;
+  }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/unit/EntityUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/unit/EntityUnitTestCase.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timestampentity/unit/EntityUnitTestCase.java	2007-02-09 00:23:02 UTC (rev 60448)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.timestampentity.unit;
+
+import java.util.Date;
+
+import org.jboss.ejb3.test.timestampentity.*;
+
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+public class EntityUnitTestCase
+extends JBossTestCase
+{
+   public EntityUnitTestCase(String name)
+   {
+
+      super(name);
+
+   }
+
+   public void testOneToMany() throws Exception
+   {
+      /* TestManager test = (TestManager) getInitialContext().lookup(TestManagerConstants.JNDI_BINDING);
+      test.createTestInteger("keyField1", 1, "keyField3", "field1", "field2", new Date());
+      test.createTestTimestamp("keyField1", 1, "keyField3", "field1", "field2", new Date());
+      
+      test.findTestInteger("keyField1", 1, "keyField3");
+      test.findTestTimestamp("keyField1", 1, "keyField3");*/
+	   
+	   TestManager testManager = (TestManager) getInitialContext().lookup(TestManagerConstants.JNDI_BINDING);
+/*	   try {
+	      testManager.createTestInteger("keyField1", 1, "keyField3", "field1", "field2", new Date(System.currentTimeMillis()));
+	      testManager.updateTestInteger("keyField1", 1, "keyField3", "field-new", "field-new", new Date(System.currentTimeMillis()));
+	    }
+	    catch (Exception e) {
+	      System.out.println("Exception caught during test #1.  " + e);
+	      e.printStackTrace();
+	    }*/
+	    System.out.println("Exectuing test #2");
+	    try {
+	      testManager.createTestTimestamp("keyField1", 1, "keyField3", "field1", "field2", new Date(System.currentTimeMillis()));
+	      testManager.updateTestTimestamp("keyField1", 1, "keyField3", "field1-new", "field2-new", new Date(System.currentTimeMillis()));
+	    }
+	    catch (Exception e) {
+	      System.out.println("Exception caught during test #2.  " + e);
+	      e.printStackTrace();
+	    }
+
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(EntityUnitTestCase.class, "timestampentity-test.jar");
+   }
+
+}




More information about the jboss-cvs-commits mailing list