details:   /erp/devel/pi/rev/0a0fb2432e0d
changeset: 8772:0a0fb2432e0d
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Oct 28 16:38:06 2010 +0200
summary:   Related to issue 14914: Error related to views in DAL: cannot modify 
a column which maps to a non key-preserved table

diffstat:

 src-test/org/openbravo/test/dal/ViewTest.java |  24 ++++++++++++++++++++++++
 src/org/openbravo/dal/core/DalUtil.java       |   2 +-
 2 files changed, 25 insertions(+), 1 deletions(-)

diffs (53 lines):

diff -r 395eb5e04f70 -r 0a0fb2432e0d 
src-test/org/openbravo/test/dal/ViewTest.java
--- a/src-test/org/openbravo/test/dal/ViewTest.java     Thu Oct 28 16:03:36 
2010 +0200
+++ b/src-test/org/openbravo/test/dal/ViewTest.java     Thu Oct 28 16:38:06 
2010 +0200
@@ -22,7 +22,10 @@
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.structure.BaseOBObject;
+import org.openbravo.dal.core.DalUtil;
+import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.materialmgmt.transaction.ShipmentInOut;
 import org.openbravo.test.base.BaseTest;
 
 /**
@@ -49,4 +52,25 @@
     assertTrue(cnt > 0);
     System.err.println(cnt);
   }
+
+  /**
+   * Tests issue https://issues.openbravo.com/view.php?id=14914 that view 
objects are not copied.
+   */
+  public void test14914() {
+    setBigBazaarUserContext();
+    OBContext.setAdminMode();
+    boolean testDone = false;
+    try {
+      for (ShipmentInOut o : 
OBDal.getInstance().createQuery(ShipmentInOut.class, "").list()) {
+        if (!o.getMaterialMgmtShipmentInOutLineVList().isEmpty()) {
+          final ShipmentInOut copied = (ShipmentInOut) DalUtil.copy(o);
+          assertTrue(copied.getMaterialMgmtShipmentInOutLineVList().isEmpty());
+          testDone = true;
+        }
+      }
+      assertTrue(testDone);
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
 }
\ No newline at end of file
diff -r 395eb5e04f70 -r 0a0fb2432e0d src/org/openbravo/dal/core/DalUtil.java
--- a/src/org/openbravo/dal/core/DalUtil.java   Thu Oct 28 16:03:36 2010 +0200
+++ b/src/org/openbravo/dal/core/DalUtil.java   Thu Oct 28 16:38:06 2010 +0200
@@ -283,7 +283,7 @@
     for (final Property p : source.getEntity().getProperties()) {
       final Object value = source.getValue(p.getName());
       if (p.isOneToMany()) {
-        if (copyChildren) {
+        if (copyChildren && !p.getTargetEntity().isView()) {
           final List<BaseOBObject> targetChildren = new 
ArrayList<BaseOBObject>();
           target.setValue(p.getName(), targetChildren);
           @SuppressWarnings("unchecked")

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to