details: /erp/devel/pi/rev/3a1e20b709fe
changeset: 8770:3a1e20b709fe
user: Martin Taal <martin.taal <at> openbravo.com>
date: Thu Oct 28 15:36:33 2010 +0200
summary: Fixes issue 14914: Error related to views in DAL: cannot modify a
column which maps to a non key-preserved table
diffstat:
src/org/openbravo/dal/core/DalMappingGenerator.java | 25 +++++++++++++++++---
1 files changed, 21 insertions(+), 4 deletions(-)
diffs (55 lines):
diff -r a96c8afc5426 -r 3a1e20b709fe
src/org/openbravo/dal/core/DalMappingGenerator.java
--- a/src/org/openbravo/dal/core/DalMappingGenerator.java Thu Oct 28
18:02:02 2010 +0530
+++ b/src/org/openbravo/dal/core/DalMappingGenerator.java Thu Oct 28
15:36:33 2010 +0200
@@ -191,10 +191,11 @@
// ignoring isUpdatable for now as this is primarily used
// for ui and not for background processes
// if (!p.isUpdatable() || p.isInactive()) {
- if (p.isInactive()) {
+
+ if (p.isInactive() || p.getEntity().isView()) {
sb.append(" update=\"false\"");
}
- if (p.isInactive()) {
+ if (p.isInactive() || p.getEntity().isView()) {
sb.append(" insert=\"false\"");
}
@@ -220,6 +221,13 @@
if (p.isMandatory()) {
sb.append(" not-null=\"true\"");
}
+
+ if (p.isInactive() || p.getEntity().isView()) {
+ sb.append(" update=\"false\"");
+ }
+ if (p.isInactive() || p.getEntity().isView()) {
+ sb.append(" insert=\"false\"");
+ }
}
// sb.append(" cascade=\"save-update\"");
@@ -254,12 +262,21 @@
order = order.replace(order.length() - 1, order.length(), "");
order.append("\"");
}
- sb.append(TAB2 + "<bag name=\"" + p.getName() + "\"
cascade=\"all,delete-orphan\" " + order
- + getAccessorAttribute() + " inverse=\"true\">" + NL);
+
+ String mutable = "";
+ String cascade = " cascade=\"all,delete-orphan\" ";
+ if (p.getEntity().isView() || p.getTargetEntity().isView()) {
+ mutable = " mutable=\"false\" ";
+ cascade = "";
+ }
+
+ sb.append(TAB2 + "<bag name=\"" + p.getName() + "\" " + cascade + order
+ + getAccessorAttribute() + mutable + " inverse=\"true\">" + NL);
sb.append(TAB3 + "<key column=\"" +
p.getReferencedProperty().getColumnName() + "\""
+ (p.getReferencedProperty().isMandatory() ? " not-null=\"true\"" :
"") + "/>" + NL);
sb.append(TAB3 + "<one-to-many entity-name=\"" +
p.getTargetEntity().getName() + "\"/>" + NL);
sb.append(TAB2 + "</bag>" + NL);
+
}
return sb.toString();
}
------------------------------------------------------------------------------
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