Package org.xorm.datastore

Examples of org.xorm.datastore.Column


        Object ownerPKey = owner.getObjectId();
        if (ownerPKey instanceof TransientKey) {
            return null;
        }

        Column columnToUse = null;
           
        if (mapping.getSource().getColumn() != null) {
            columnToUse = mapping.getSource().getColumn();
        }
        else if (mapping.getFilter() != null) {
            // In this case, source wasn't specified, but target
            // is always specified...and in this case should be
            // the primary key column of the owner class (see
            // ModelMapping.parseRelationship).
            columnToUse = mapping.getTarget().getColumn();
        }
        else {
            // How did we get here?  An exception should have been
            // thrown in ModelMapping.parseRelationship
            throw new JDOFatalUserException(I18N.msg("E_collection_no_source"));
        }
 
        Selector selector = new Selector
            (columnToUse.getTable(),
             new SimpleCondition(columnToUse, Operator.EQUAL, ownerPKey));
       
        if (mapping.getFilter() != null) {
            logger.fine("Filter: " + mapping.getFilter());
            logger.fine("Imports: " + mapping.getImports());
View Full Code Here


    /** Called when an object ID changes. */
    public void notifyIDChanged(Object oldID, Object newID) {
        // Go through Rows and look for references to oldID
        Iterator i = getRows().iterator();
        Column c1 = mapping.getTarget().getColumn();
        Column c2 = mapping.getSource().getColumn();
        while (i.hasNext()) {
            Row row = (Row) i.next();
            if (oldID.equals(row.getValue(c1))) {
                row.setValue(c1, newID);
            }
View Full Code Here

            while (exts.hasNext()) {
                extension = (JDOExtension) exts.next();
                if (XORM_VENDOR_NAME.equals(extension.getVendorName())) {
                    String key = extension.getKey();
                    if ("column".equals(key)) {
                        Column c2 = t.getColumnByName(extension.getValue());
                        if (c2 == null) {
                            throw new JDOFatalUserException(I18N.msg("E_no_column", extension.getValue(), t.getName(), jdoClass.getName()));
                        }
                        classMapping.setColumn(field.getName(), c2, field.isDefaultFetchGroup());
                        if (field.getNullValue().equals(JDONullValue.EXCEPTION)) {
                            // TODO: should this be done here?
                            c2.setNonNull(true);
                        }
                    } else if ("inverse".equals(key)) {
                        classMapping.setInverse(field.getName(), extension.getValue());
                    }
                } // XORM is vendor-name
View Full Code Here

            relationship.setMToN(true);
            target.setColumn(table.getColumnByName(targetStr));
        }

        if (indexStr != null) {
            Column c = table.getColumnByName(indexStr);
            // Set the column to managed mode; we don't want
            // indices to be included in Row.equals() operations
            c.setManaged(true);
            relationship.setIndexColumn(c);
        }

        if (filterStr != null && !filterStr.equals("")) {
            relationship.setFilter(filterStr);
View Full Code Here

            nameToTable.put(tableName, table);
            List columns = element.getChildren("column");
            Iterator j = columns.iterator();
            while (j.hasNext()) {
                Element colElement = (Element) j.next();
                Column column = new Column(table, colElement.getAttributeValue("name"));
                if ("true".equalsIgnoreCase(colElement.getAttributeValue("primary-key"))) {
                    table.setPrimaryKey(column);
                }
                if ("true".equalsIgnoreCase(colElement.getAttributeValue("read-only"))) {
                    column.setReadOnly(true);
                }
                if ("true".equalsIgnoreCase(colElement.getAttributeValue("non-null"))) {
                    column.setNonNull(true);
                }
                // Is it a sequenced column?
                if (colElement.getAttributeValue("sequence") != null) {
                    column.setSequence(colElement.getAttributeValue("sequence"));
                }
                // Is it an autoincremented column?
                if ("true".equalsIgnoreCase(colElement.getAttributeValue("auto"))) {
                    column.setAutoIncremented(true);
                }
                // Is it manually typed?
                column.setType(colElement.getAttributeValue("type"));
                column.setFormat(colElement.getAttributeValue("format"));
            } // columns iterator
            // map the table for later reference
        } // tables iterator
    }
View Full Code Here

                enterTransaction(txn);
            }
        }
 
        String field = mapping.getFieldForMethod(method);
        Column c = mapping.getColumnForMethod(method);
        if (c == null) {
            RelationshipMapping rm = mapping.getRelationshipForMethod(method);
            if (rm == null) return null;
            if (args == null || args.length == 0) {
                // Relationship read method
View Full Code Here

    /**
     * Returns the object associated with the given field that
     * is of the given return type.
     */
    public Object invokeGet(String field, ClassMapping returnTypeMapping, Class returnType) {
        Column c = mapping.getColumn(field);
        if (c == null) throw new JDOUserException("No column for field " + field + " of class " + mapping.getMappedClass().getName());
        if (!getRow().containsValue(c)) {
            // Column fault: column was not in default fetch group
            DataFetchGroup dfg = new DataFetchGroup();
            dfg.addColumn(c);
View Full Code Here

    // CRUD methods
    public void create(Row row)  {
  onlyDidReads = false;
  Table table = row.getTable();
  Column primaryKey = table.getPrimaryKey();

  Element element = new Element(table.getName());
  row.setValue(primaryKey, element);

  Iterator it = table.getColumns().iterator();
  while (it.hasNext()) {
      Column c = (Column) it.next();
      setValue(element, c, row.getValue(c), true);
  }
  // If the newly created element is unattached at this point,
  // it is not contained within any other element tag, and therefore
  // it must be added under the document root.
View Full Code Here

    }

    public void update(Row row) {
  onlyDidReads = false;
  Table table = row.getTable();
  Column primaryKey = table.getPrimaryKey();

  Element element = (Element) row.getValue(primaryKey);
  Iterator it = table.getColumns().iterator();
  while (it.hasNext()) {
      Column c = (Column) it.next();
      if (row.isDirty(c)) {
    setValue(element, c, row.getValue(c), false);
      }
  }
    }
View Full Code Here

    }

    public void delete(Row row) {
  onlyDidReads = false;
  Table table = row.getTable();
  Column primaryKey = table.getPrimaryKey();

  Element element = (Element) row.getValue(primaryKey);
  element.detach();
  // TODO: deal with cascaded delete ramifications on the cache
    }
View Full Code Here

TOP

Related Classes of org.xorm.datastore.Column

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.