Index: src/bugs/jdo/bug1217/CompanyProduct.java
===================================================================
RCS file: src/bugs/jdo/bug1217/CompanyProduct.java
diff -N src/bugs/jdo/bug1217/CompanyProduct.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/CompanyProduct.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,80 @@
+package jdo.bug1217;
+
+import org.exolab.castor.jdo.TimeStampable;
+
+/**
+ * @author cwichoski
+ */
+public class CompanyProduct implements TimeStampable {
+
+ long $timestamp;
+
+ String oid;
+ String code;
+ Double sellValue;
+ Person myCompany;
+ Product myProduct;
+
+ public CompanyProduct() {
+ }
+ public CompanyProduct(String oid, String code, Double sellValue, Person company, Product product) {
+ this.setOid(oid);
+ this.setCode(code);
+ this.setSellValue(sellValue);
+ this.setMyCompany(company);
+ this.setMyProduct(product);
+ }
+
+ public void setOid(String oid) {
+ this.oid = oid;
+ }
+ public String getOid() {
+ return this.oid;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+ public String getCode() {
+ return this.code;
+ }
+
+ public void setSellValue(Double sellValue) {
+ this.sellValue = sellValue;
+ }
+ public Double getSellValue() {
+ return this.sellValue;
+ }
+
+ public void setMyCompany(Person company) {
+ this.myCompany = company;
+ }
+ public Person getMyCompany() {
+ return this.myCompany;
+ }
+
+ public void setMyProduct(Product product) {
+ this.myProduct = product;
+ }
+ public Product getMyProduct() {
+ return this.myProduct;
+ }
+
+ public String toString() {
+ return super.toString()+
+ " { oid: '"+this.getOid()+
+ "', code: '"+this.getCode()+
+ "', value: '"+this.getSellValue()+
+ "', myCompany: '"+this.getMyCompany()+
+ "', myProduct: '"+this.getMyProduct()+
+ "', timestamp: "+this.jdoGetTimeStamp()+
+ " }";
+ }
+
+ public void jdoSetTimeStamp(long timestamp) {
+ this.$timestamp = timestamp;
+ }
+ public long jdoGetTimeStamp() {
+ return this.$timestamp;
+ }
+}
Index: src/bugs/jdo/bug1217/Invoice.java
===================================================================
RCS file: src/bugs/jdo/bug1217/Invoice.java
diff -N src/bugs/jdo/bug1217/Invoice.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/Invoice.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,112 @@
+package jdo.bug1217;
+
+import java.util.Vector;
+import org.exolab.castor.jdo.TimeStampable;
+
+/**
+ * @author cwichoski
+ */
+public class Invoice implements TimeStampable {
+
+ long $timestamp;
+
+ String oid;
+ Integer number;
+ Person myCompany;
+ Person myClient;
+ Vector myInvoiceItem;
+
+ public Invoice() {
+ }
+ public Invoice(String oid, Integer number, Person company, Person client) {
+ this.setOid(oid);
+ this.setNumber(number);
+ this.setMyCompany(company);
+ this.setMyClient(client);
+ }
+
+ public void setOid(String oid) {
+ this.oid = oid;
+ }
+ public String getOid() {
+ return this.oid;
+ }
+
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+ public Integer getNumber() {
+ return this.number;
+ }
+
+ public void setMyCompany(Person company) {
+ this.myCompany = company;
+ }
+ public Person getMyCompany() {
+ return this.myCompany;
+ }
+
+ public void setMyClient(Person company) {
+ this.myClient = company;
+ }
+ public Person getMyClient() {
+ return this.myClient;
+ }
+
+ public void setMyInvoiceItem(java.util.Vector myInvoiceItem) {
+ this.myInvoiceItem = myInvoiceItem;
+ }
+ public java.util.Vector getMyInvoiceItem() {
+ return this.myInvoiceItem;
+ }
+ public void addInvoiceItem(InvoiceItem newInvoiceItem) {
+ newInvoiceItem.setMyInvoice(this);
+ if (myInvoiceItem == null) {
+ myInvoiceItem = new java.util.Vector();
+ }
+ myInvoiceItem.add(newInvoiceItem);
+ }
+ public boolean removeInvoiceItem(String oid) {
+ boolean removed = false;
+ if (this.myInvoiceItem != null) {
+ InvoiceItem invoiceItem = null;
+ for ( int n = 0; n < this.myInvoiceItem.size(); n++ ) {
+ invoiceItem = (InvoiceItem)this.myInvoiceItem.get(n);
+ if ( invoiceItem.getOid().equals(oid) ) {
+ this.myInvoiceItem.remove(n);
+ removed = true;
+ break;
+ }
+ }
+ }
+ return removed;
+ }
+ public InvoiceItem getInvoiceItem(String oid) {
+ InvoiceItem invoiceItem = null;
+ if (this.myInvoiceItem != null) {
+ for ( int n = 0; n < this.myInvoiceItem.size(); n++ ) {
+ invoiceItem = (InvoiceItem)this.myInvoiceItem.get(n);
+ if (invoiceItem.getOid().equals(oid)) {
+ break;
+ }
+ }
+ }
+ return invoiceItem;
+ }
+
+ public String toString() {
+ return super.toString()+
+ " { oid: '"+this.getOid()+
+ "', number: '"+this.getNumber()+
+ "', myInvoiceItem: '"+this.getMyInvoiceItem()+
+ "', timestamp: "+this.jdoGetTimeStamp()+
+ " }";
+ }
+
+ public void jdoSetTimeStamp(long timestamp) {
+ this.$timestamp = timestamp;
+ }
+ public long jdoGetTimeStamp() {
+ return this.$timestamp;
+ }
+}
Index: src/bugs/jdo/bug1217/InvoiceItem.java
===================================================================
RCS file: src/bugs/jdo/bug1217/InvoiceItem.java
diff -N src/bugs/jdo/bug1217/InvoiceItem.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/InvoiceItem.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,78 @@
+package jdo.bug1217;
+
+import org.exolab.castor.jdo.TimeStampable;
+
+/**
+ * @author cwichoski
+ */
+public class InvoiceItem implements TimeStampable {
+
+ long $timestamp;
+
+ String oid;
+ Integer quantity;
+ Double unitValue;
+ Product myProduct;
+ Invoice myInvoice;
+
+ public InvoiceItem() {
+ }
+ public InvoiceItem(String oid, Integer quantity, Double unitValue, Product product) {
+ this.setOid(oid);
+ this.setQuantity(quantity);
+ this.setUnitValue(unitValue);
+ this.setMyProduct(product);
+ }
+
+ public void setOid(String oid) {
+ this.oid = oid;
+ }
+ public String getOid() {
+ return this.oid;
+ }
+
+ public void setQuantity(Integer quantity) {
+ this.quantity = quantity;
+ }
+ public Integer getQuantity() {
+ return this.quantity;
+ }
+
+ public void setUnitValue(Double value) {
+ this.unitValue = value;
+ }
+ public Double getUnitValue() {
+ return this.unitValue;
+ }
+
+ public void setMyProduct(Product newProduct) {
+ this.myProduct = newProduct;
+ }
+ public Product getMyProduct() {
+ return this.myProduct;
+ }
+
+ public void setMyInvoice(Invoice newInvoice) {
+ this.myInvoice = newInvoice;
+ }
+ public Invoice getMyInvoice() {
+ return this.myInvoice;
+ }
+
+ public String toString() {
+ return super.toString()+
+ " { oid: '"+this.getOid()+
+ "', quantity: '"+this.getQuantity()+
+ "', myProduct: '"+this.getMyProduct()+
+ "', timestamp: "+this.jdoGetTimeStamp()+
+ " }";
+ }
+
+ public void jdoSetTimeStamp(long timestamp) {
+ this.$timestamp = timestamp;
+ }
+ public long jdoGetTimeStamp() {
+ return this.$timestamp;
+ }
+}
+
Index: src/bugs/jdo/bug1217/Part.java
===================================================================
RCS file: src/bugs/jdo/bug1217/Part.java
diff -N src/bugs/jdo/bug1217/Part.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/Part.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,24 @@
+package jdo.bug1217;
+
+/**
+ * @author cwichoski
+ */
+public class Part extends Product {
+
+ String factoryNumber;
+
+ public Part() {
+ }
+ public Part(String oid, String name, String factoryNumber) {
+ super(oid,name);
+ this.setFactoryNumber(factoryNumber);
+ }
+
+ public void setFactoryNumber(String newFactoryNumber) {
+ this.factoryNumber = newFactoryNumber;
+ }
+ public String getFactoryNumber() {
+ return this.factoryNumber;
+ }
+
+}
Index: src/bugs/jdo/bug1217/Person.java
===================================================================
RCS file: src/bugs/jdo/bug1217/Person.java
diff -N src/bugs/jdo/bug1217/Person.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/Person.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,51 @@
+package jdo.bug1217;
+
+import org.exolab.castor.jdo.TimeStampable;
+
+/**
+ * @author cwichoski
+ */
+public class Person implements TimeStampable {
+
+ long $timestamp;
+
+ String oid;
+ String name;
+
+ public Person() {
+ }
+
+ public Person(String oid, String name) {
+ this.setOid(oid);
+ this.setName(name);
+ }
+
+ public void setOid(String oid) {
+ this.oid = oid;
+ }
+ public String getOid() {
+ return this.oid;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getName() {
+ return this.name;
+ }
+
+ public String toString() {
+ return super.toString()+
+ " { oid: '"+this.getOid()+
+ "', name: '"+this.getName()+
+ "', timestamp: "+this.jdoGetTimeStamp()+
+ " }";
+ }
+
+ public void jdoSetTimeStamp(long timestamp) {
+ this.$timestamp = timestamp;
+ }
+ public long jdoGetTimeStamp() {
+ return this.$timestamp;
+ }
+}
Index: src/bugs/jdo/bug1217/Product.java
===================================================================
RCS file: src/bugs/jdo/bug1217/Product.java
diff -N src/bugs/jdo/bug1217/Product.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/Product.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,51 @@
+package jdo.bug1217;
+
+import org.exolab.castor.jdo.TimeStampable;
+
+/**
+ * @author cwichoski
+ */
+public class Product implements TimeStampable {
+
+ long $timestamp;
+
+ String oid;
+ String name;
+
+ public Product() {
+ }
+
+ public Product(String oid, String name) {
+ this.setOid(oid);
+ this.setName(name);
+ }
+
+ public void setOid(String oid) {
+ this.oid = oid;
+ }
+ public String getOid() {
+ return this.oid;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getName() {
+ return this.name;
+ }
+
+ public String toString() {
+ return super.toString()+
+ " { oid: '"+this.getOid()+
+ "', name: '"+this.getName()+
+ "', timestamp: "+this.jdoGetTimeStamp()+
+ " }";
+ }
+
+ public void jdoSetTimeStamp(long timestamp) {
+ this.$timestamp = timestamp;
+ }
+ public long jdoGetTimeStamp() {
+ return this.$timestamp;
+ }
+}
Index: src/bugs/jdo/bug1217/README.txt
===================================================================
RCS file: src/bugs/jdo/bug1217/README.txt
diff -N src/bugs/jdo/bug1217/README.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/README.txt 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,5 @@
+bug number: 1217
+description: Wrong timestamps for same object having hirarchy when loaded by many referers.
+castor: version 0.9.9 or CVS of 2005-09-12 11:00
+database: SAPDB 7.3
+driver: sapdbc.jar (ftp://ftp.sap.com/pub/sapdb/bin/java/sapdbc.jar)
Index: src/bugs/jdo/bug1217/TestChangeTimestamp.java
===================================================================
RCS file: src/bugs/jdo/bug1217/TestChangeTimestamp.java
diff -N src/bugs/jdo/bug1217/TestChangeTimestamp.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/TestChangeTimestamp.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,238 @@
+package jdo.bug1217;
+
+import java.sql.Connection;
+import java.util.Iterator;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.castor.jdo.engine.ConnectionFactory;
+import org.exolab.castor.jdo.Database;
+import org.exolab.castor.jdo.JDOManager;
+import org.exolab.castor.jdo.OQLQuery;
+import org.exolab.castor.jdo.QueryResults;
+
+public final class TestChangeTimestamp extends TestCase {
+ private static final String JDO_CONF_FILE = "jdo-conf.xml";
+ private static final String DATABASE_NAME = "bug1217";
+ private static final String JDO_CONF_FILE_AUX = "jdo-confAux.xml";
+ private static final String DATABASE_NAME_AUX = "bug1217Aux";
+
+ private static Log _log = null;
+
+ private static JDOManager _jdo = null;
+ private static JDOManager _jdoAux = null;
+
+ public static void main(final String[] args) throws Exception {
+ _log = LogFactory.getLog(TestChangeTimestamp.class);
+
+ String config = TestChangeTimestamp.class.getResource(JDO_CONF_FILE).toString();
+ JDOManager.loadConfiguration(config, TestChangeTimestamp.class.getClassLoader());
+ _jdo = JDOManager.createInstance(DATABASE_NAME);
+
+ String configAux = TestChangeTimestamp.class.getResource(JDO_CONF_FILE_AUX).toString();
+ JDOManager.loadConfiguration(configAux, TestChangeTimestamp.class.getClassLoader());
+ _jdoAux = JDOManager.createInstance(DATABASE_NAME_AUX);
+
+ TestChangeTimestamp test = new TestChangeTimestamp();
+ test.setUp();
+
+ test.testDeleteData();
+ test.testPopulateData();
+ test.testLoad();
+
+ test.tearDown();
+ }
+
+ public static Test suite() throws Exception {
+ _log = LogFactory.getLog(TestChangeTimestamp.class);
+
+ String config = TestChangeTimestamp.class.getResource(JDO_CONF_FILE).toString();
+ JDOManager.loadConfiguration(config, TestChangeTimestamp.class.getClassLoader());
+ _jdo = JDOManager.createInstance(DATABASE_NAME);
+
+ String configAux = TestChangeTimestamp.class.getResource(JDO_CONF_FILE_AUX).toString();
+ JDOManager.loadConfiguration(configAux, TestChangeTimestamp.class.getClassLoader());
+ _jdoAux = JDOManager.createInstance(DATABASE_NAME_AUX);
+
+ TestSuite suite = new TestSuite("bug1217 Tests");
+
+ suite.addTest(new TestChangeTimestamp("testDeleteData"));
+ suite.addTest(new TestChangeTimestamp("testPopulateData"));
+ suite.addTest(new TestChangeTimestamp("testLoad"));
+
+ return suite;
+ }
+
+ public TestChangeTimestamp() {
+ super();
+ }
+
+ public TestChangeTimestamp(final String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testDeleteData() throws Exception {
+ ConnectionFactory cf = _jdo.getConnectionFactory();
+ Connection con = cf.createConnection();
+ con.createStatement().execute("DELETE FROM COMPANYPRODUCT");
+ con.createStatement().execute("DELETE FROM INVOICEITEM");
+ con.createStatement().execute("DELETE FROM INVOICE");
+ con.createStatement().execute("DELETE FROM PART");
+ con.createStatement().execute("DELETE FROM PRODUCT");
+ con.createStatement().execute("DELETE FROM PERSON");
+ con.close();
+ }
+
+ public void testPopulateData() throws Exception {
+ Product[] product = new Product[100];
+ Person company = null;
+ Person[] client = new Person[20];
+ CompanyProduct[] companyProduct = new CompanyProduct[100];
+ Invoice invoice = null;
+ InvoiceItem invoiceItem = null;
+
+ Database db = _jdo.getDatabase();
+ db.begin();
+
+ //creates company
+ company = new Person("CP1","COMPANY 1");
+ db.create(company);
+
+ //creates 20 clients
+ for (int n = 0; n < 20; n++) {
+ client[n] = new Person("CL"+n,"CLIENT "+n);
+ db.create(client[n]);
+ }
+
+ //creates 100 products and respectives Company - Products
+ for (int n = 0; n < 100; n++) {
+ product[n] = new Part("PD"+n,"PRODUCT "+n,"FACTN"+n);
+ db.create(product[n]);
+
+ companyProduct[n] = new CompanyProduct(
+ "CPPD"+n,
+ Integer.toString(n),
+ new Double(100 * Math.random()),
+ company,
+ product[n]
+ );
+ db.create(companyProduct[n]);
+ }
+
+ //Company sell products to all clients with 20 itens each
+ int itemCount = -1;
+ int sellNumber = -1;
+ for (int clientNumber = 0; clientNumber < 20; clientNumber++) {
+ sellNumber++;
+ invoice = new Invoice(
+ "IV"+sellNumber,
+ new Integer(sellNumber),
+ company,
+ client[clientNumber]
+ );
+
+ int nProduct = -1;
+ String itemOid = null;
+ int qty = -1;
+ for (int itemNumber = 0; itemNumber < 20; itemNumber++) {
+ itemCount++;
+ nProduct = Integer.parseInt(Long.toString(99-Math.round(99 * Math.random())));
+ itemOid = "II"+itemCount;
+ qty = Integer.parseInt(Long.toString(31-Math.round(30 * Math.random())));
+
+ invoiceItem = new InvoiceItem(
+ itemOid,
+ new Integer(qty),
+ companyProduct[nProduct].getSellValue(),
+ product[nProduct]
+ );
+ invoice.addInvoiceItem(invoiceItem);
+ }
+ db.create(invoice);
+ }
+
+ db.commit();
+
+ db.close();
+ }
+
+ public void testLoad() throws Exception {
+ Database db;
+ Invoice invoice = null;
+ InvoiceItem invoiceItem;
+ Product product;
+ CompanyProduct companyProduct;
+ Hashtable htCompanyProduct = new Hashtable();
+ Hashtable htProduct = new Hashtable();
+
+
+ //1st Transaction ClientApp query for an invoice using JDO without cache
+ db = _jdoAux.getDatabase();
+ db.begin();
+ OQLQuery query = db.getOQLQuery("SELECT invoice FROM jdo.bug1217.Invoice invoice WHERE myCompany = $1 AND number = $2");
+ query.bind("CP1");
+ query.bind(15);
+ QueryResults results = query.execute(Database.ReadOnly);
+ if (results.hasMore()) {
+ invoice = (Invoice)results.next();
+ }
+ db.commit();
+ db.close();
+
+ //Client load the invoice using cache JDO
+ db = _jdo.getDatabase();
+ db.begin();
+ invoice = (Invoice)db.load(Invoice.class,invoice.getOid());
+ db.commit();
+ db.close();
+
+ //ClientApp must check all invoice item to check if sellValue in company has changed
+ Iterator itens = invoice.getMyInvoiceItem().iterator();
+ while (itens.hasNext()) {
+ invoiceItem = (InvoiceItem)itens.next();
+ product = invoiceItem.getMyProduct();
+ htProduct.put(product.getOid(),product);
+ }
+
+ db = _jdo.getDatabase();
+ db.begin();
+ query = db.getOQLQuery("SELECT obj FROM jdo.bug1217.CompanyProduct obj WHERE myCompany = $1 AND myProduct = $2");
+ Enumeration products = htProduct.elements();
+ while (products.hasMoreElements()) {
+ product = (Product)products.nextElement();
+ query.bind("CP1");
+ query.bind(product.getOid());
+ results = query.execute(Database.ReadOnly);
+ if (results.hasMore()) {
+ companyProduct = (CompanyProduct)results.next();
+ htCompanyProduct.put(product.getOid(),companyProduct);
+ }
+ }
+ db.commit();
+ db.close();
+
+ products = htProduct.elements();
+ while (products.hasMoreElements()) {
+ product = (Product)products.nextElement();
+ companyProduct = (CompanyProduct)htCompanyProduct.get(product.getOid());
+ assertEquals("Timestamp must be equals!",product.jdoGetTimeStamp(),companyProduct.getMyProduct().jdoGetTimeStamp());
+ }
+
+ }
+
+}
Index: src/bugs/jdo/bug1217/jdo-conf.xml
===================================================================
RCS file: src/bugs/jdo/bug1217/jdo-conf.xml
diff -N src/bugs/jdo/bug1217/jdo-conf.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/jdo-conf.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/bugs/jdo/bug1217/jdo-confAux.xml
===================================================================
RCS file: src/bugs/jdo/bug1217/jdo-confAux.xml
diff -N src/bugs/jdo/bug1217/jdo-confAux.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/jdo-confAux.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/bugs/jdo/bug1217/mapping.xml
===================================================================
RCS file: src/bugs/jdo/bug1217/mapping.xml
diff -N src/bugs/jdo/bug1217/mapping.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/mapping.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+ Person
+
+
+
+
+
+
+
+
+
+
+
+
+ Product
+
+
+
+
+
+
+
+
+
+
+
+
+ Part
+
+
+
+
+
+
+
+
+
+
+
+
+ Company Product
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Invoice
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OrderItem
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/bugs/jdo/bug1217/mappingAux.xml
===================================================================
RCS file: src/bugs/jdo/bug1217/mappingAux.xml
diff -N src/bugs/jdo/bug1217/mappingAux.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/mappingAux.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+ Person
+
+
+
+
+
+
+
+
+
+
+
+ Product
+
+
+
+
+
+
+
+
+
+
+
+ Part
+
+
+
+
+
+
+
+
+
+
+
+ Company Product
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Invoice
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OrderItem
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/bugs/jdo/bug1217/mysql.sql
===================================================================
RCS file: src/bugs/jdo/bug1217/mysql.sql
diff -N src/bugs/jdo/bug1217/mysql.sql
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/mysql.sql 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,68 @@
+DROP TABLE if exists INVOICEITEM;
+
+DROP TABLE if exists INVOICE;
+
+DROP TABLE if exists COMPANYPRODUCT;
+
+DROP TABLE if exists PERSON;
+
+DROP TABLE if exists PART;
+
+DROP TABLE if exists PRODUCT;
+
+CREATE TABLE PERSON (
+ OID VARCHAR(8) NOT NULL,
+ NAME VARCHAR(60) NOT NULL,
+ PRIMARY KEY (OID)
+);
+
+CREATE TABLE PRODUCT (
+ OID VARCHAR(8) NOT NULL,
+ NAME VARCHAR(60) NOT NULL,
+ PRIMARY KEY (OID)
+);
+
+CREATE TABLE PART (
+ OID VARCHAR(8) NOT NULL,
+ FACTORY_NUMBER VARCHAR(20) NOT NULL,
+ PRIMARY KEY (OID)
+);
+
+ALTER TABLE PART ADD FOREIGN KEY (OID) REFERENCES PRODUCT(OID);
+
+CREATE TABLE COMPANYPRODUCT (
+ OID VARCHAR(8) NOT NULL,
+ CODE VARCHAR(12) NOT NULL,
+ SELL_VALUE NUMBER(12,2) NOT NULL,
+ MY_COMPANY VARCHAR(8) NOT NULL,
+ MY_PRODUCT VARCHAR(8) NOT NULL,
+ PRIMARY KEY (OID)
+);
+
+ALTER TABLE COMPANYPRODUCT ADD FOREIGN KEY (MY_COMPANY) REFERENCES PERSON(OID);
+
+ALTER TABLE COMPANYPRODUCT ADD FOREIGN KEY (MY_PRODUCT) REFERENCES PRODUCT(OID);
+
+CREATE TABLE INVOICE (
+ OID VARCHAR(8) NOT NULL,
+ NUMBER_OF INTEGER NOT NULL,
+ MY_COMPANY VARCHAR(8) NOT NULL,
+ MY_CLIENT VARCHAR(8) NOT NULL,
+ PRIMARY KEY (OID)
+);
+
+ALTER TABLE COMPANYPRODUCT ADD FOREIGN KEY (MY_COMPANY) REFERENCES PERSON(OID);
+
+ALTER TABLE COMPANYPRODUCT ADD FOREIGN KEY (MY_CLIENT) REFERENCES PERSON(OID);
+
+CREATE TABLE INVOICEITEM (
+ OID VARCHAR(8) NOT NULL,
+ QUANTITY INTEGER NOT NULL,
+ MY_PRODUCT VARCHAR(8),
+ MY_ORDER VARCHAR(8) NOT NULL,
+ PRIMARY KEY (OID)
+);
+
+ALTER TABLE INVOICEITEM ADD FOREIGN KEY (MY_PRODUCT) REFERENCES PRODUCT(OID);
+
+ALTER TABLE INVOICEITEM ADD FOREIGN KEY (MY_INVOICE) REFERENCES INVOICE(OID);
Index: src/bugs/jdo/bug1217/sapdb.sql
===================================================================
RCS file: src/bugs/jdo/bug1217/sapdb.sql
diff -N src/bugs/jdo/bug1217/sapdb.sql
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/bugs/jdo/bug1217/sapdb.sql 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,71 @@
+DROP TABLE PERSON
+//
+CREATE TABLE PERSON (
+ OID VARCHAR(8) NOT NULL,
+ NAME VARCHAR(60) NOT NULL,
+ PRIMARY KEY (OID)
+)
+//
+DROP TABLE PRODUCT
+//
+CREATE TABLE PRODUCT (
+ OID VARCHAR(8) NOT NULL,
+ NAME VARCHAR(60) NOT NULL,
+ PRIMARY KEY (OID)
+)
+//
+DROP TABLE PART
+//
+CREATE TABLE PART (
+ OID VARCHAR(8) NOT NULL,
+ FACTORY_NUMBER VARCHAR(60) NOT NULL,
+ PRIMARY KEY (OID)
+)
+//
+ALTER TABLE PART ADD FOREIGN KEY(OID) REFERENCES PRODUCT(OID)
+//
+DROP TABLE COMPANYPRODUCT
+//
+CREATE TABLE COMPANYPRODUCT (
+ OID VARCHAR(8) NOT NULL,
+ CODE VARCHAR(12) NOT NULL,
+ SELL_VALUE FIXED(12,2) NOT NULL,
+ MY_COMPANY VARCHAR(8) NOT NULL,
+ MY_PRODUCT VARCHAR(8) NOT NULL,
+ PRIMARY KEY (OID)
+)
+//
+ALTER TABLE COMPANYPRODUCT ADD FOREIGN KEY (MY_COMPANY) REFERENCES PERSON(OID)
+//
+ALTER TABLE COMPANYPRODUCT ADD FOREIGN KEY (MY_PRODUCT) REFERENCES PRODUCT(OID)
+//
+DROP TABLE INVOICE
+//
+CREATE TABLE INVOICE (
+ OID VARCHAR(8) NOT NULL,
+ NUMBER_OF INTEGER NOT NULL,
+ MY_COMPANY VARCHAR(8) NOT NULL,
+ MY_CLIENT VARCHAR(8) NOT NULL,
+ PRIMARY KEY (OID)
+)
+//
+ALTER TABLE INVOICE ADD FOREIGN KEY (MY_COMPANY) REFERENCES PERSON(OID)
+//
+ALTER TABLE INVOICE ADD FOREIGN KEY (MY_CLIENT) REFERENCES PERSON(OID)
+//
+DROP TABLE INVOICEITEM
+//
+CREATE TABLE INVOICEITEM (
+ OID VARCHAR(8) NOT NULL,
+ QUANTITY INTEGER NOT NULL,
+ UNIT_VALUE FIXED(12,2) NOT NULL,
+ MY_PRODUCT VARCHAR(8),
+ MY_INVOICE VARCHAR(8) NOT NULL,
+ PRIMARY KEY (OID)
+)
+//
+ALTER TABLE INVOICEITEM ADD FOREIGN KEY (MY_PRODUCT) REFERENCES PRODUCT(OID)
+//
+ALTER TABLE INVOICEITEM ADD FOREIGN KEY (MY_INVOICE) REFERENCES INVOICE(OID)
+//
+