Distinguish between complex reference and multi-constraint.
Some initial code for unset-constraint in Node.unset() TODO: we need to make sure Relation.getDbField() returns the correct value for non-complex references!
This commit is contained in:
		
							parent
							
								
									25d2e65674
								
							
						
					
					
						commit
						25255ad5da
					
				
					 2 changed files with 25 additions and 5 deletions
				
			
		| 
						 | 
					@ -2369,12 +2369,14 @@ public final class Node implements INode, Serializable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Relation rel = (dbmap == null) ? null : dbmap.getPropertyRelation(propname);
 | 
					        Relation rel = (dbmap == null) ? null : dbmap.getPropertyRelation(propname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (rel != null && rel.isComplexReference()) {
 | 
					        if (rel != null && (rel.countConstraints() > 1 || rel.isComplexReference())) {
 | 
				
			||||||
            rel.setConstraints(this, n);
 | 
					            rel.setConstraints(this, n);
 | 
				
			||||||
 | 
					            if (rel.isComplexReference()) {
 | 
				
			||||||
                Key key = new MultiKey(n.getDbMapping(), rel.getKeyParts(this));
 | 
					                Key key = new MultiKey(n.getDbMapping(), rel.getKeyParts(this));
 | 
				
			||||||
                nmgr.nmgr.registerNode(n, key);
 | 
					                nmgr.nmgr.registerNode(n, key);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Property prop = (propMap == null) ? null : (Property) propMap.get(p2);
 | 
					        Property prop = (propMap == null) ? null : (Property) propMap.get(p2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2485,6 +2487,15 @@ public final class Node implements INode, Serializable {
 | 
				
			||||||
                if (state == CLEAN) {
 | 
					                if (state == CLEAN) {
 | 
				
			||||||
                    markAs(MODIFIED);
 | 
					                    markAs(MODIFIED);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            } else if (dbmap != null) {
 | 
				
			||||||
 | 
					                // check if this is a complex constraint and we have to
 | 
				
			||||||
 | 
					                // unset constraints.
 | 
				
			||||||
 | 
					                Relation rel = dbmap.getExactPropertyRelation(propname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (rel != null && (rel.isComplexReference() || rel.countConstraints() > 1)) {
 | 
				
			||||||
 | 
					                    p = getProperty(propname);
 | 
				
			||||||
 | 
					                    System.err.println ("NEED TO UNSET: "+p.getNodeValue());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch (Exception ignore) {
 | 
					        } catch (Exception ignore) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -176,7 +176,7 @@ public final class Relation {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // check if this is a non-trivial reference
 | 
					            // check if this is a non-trivial reference
 | 
				
			||||||
            if (reftype == REFERENCE) {
 | 
					            if (reftype == REFERENCE) {
 | 
				
			||||||
                if (constraints.length > 1 || !usesPrimaryKey()) {
 | 
					                if (constraints.length > 0 && !usesPrimaryKey()) {
 | 
				
			||||||
                    reftype = COMPLEX_REFERENCE;
 | 
					                    reftype = COMPLEX_REFERENCE;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -323,6 +323,15 @@ public final class Relation {
 | 
				
			||||||
        return isPrivate;
 | 
					        return isPrivate;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     *  Returns the number of constraints for this relation.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int countConstraints() {
 | 
				
			||||||
 | 
					        if (constraints == null)
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        return constraints.length;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     *  Returns true if the object represented by this Relation has to be
 | 
					     *  Returns true if the object represented by this Relation has to be
 | 
				
			||||||
     *  created dynamically by the Helma objectmodel runtime as a virtual
 | 
					     *  created dynamically by the Helma objectmodel runtime as a virtual
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue