Package org.apache.ojb.broker.metadata

Examples of org.apache.ojb.broker.metadata.FieldDescriptor


    {
        PBCapsule capsule = new PBCapsule(null, TxManagerFactory.instance().getTransaction());
        try
        {
            PersistenceBroker broker = capsule.getBroker();
            FieldDescriptor fld = broker.getClassDescriptor(this.getClass()).getAutoIncrementFields()[0];
            Integer val = (Integer) broker.serviceSequenceManager().getUniqueValue(fld);

            int result = val.intValue();
            return result;
        }
View Full Code Here


            String className = (String) source.get(CLASS_NAME_STR);
            ClassDescriptor cld = broker.getDescriptorRepository().getDescriptorFor(className);
            Object target = ClassHelper.buildNewObjectInstance(cld);
            // perform main object values
            FieldDescriptor[] flds = cld.getFieldDescriptions();
            FieldDescriptor fld = null;
            for(int i = 0; i < flds.length; i++)
            {
                fld = flds[i];
                // read the field value
                Object value = source.get(fld.getPersistentField().getName());
                // copy the field value
                value = fld.getJdbcType().getFieldType().copy(value);
                // now make a field-conversion to java-type, because we only
                // the sql type of the field
                value = fld.getFieldConversion().sqlToJava(value);
                // set the copied field value in new object
                fld.getPersistentField().set(target, value);
            }
            return target;
        }
View Full Code Here

            ClassDescriptor cld = broker.getClassDescriptor(obj.getClass());
            // we store field values by name in a Map
            HashMap target = oldObject != null ? (HashMap) oldObject : new HashMap();
            // perform main object values
            FieldDescriptor[] flds = cld.getFieldDescriptions();
            FieldDescriptor fld = null;
            for(int i = 0; i < flds.length; i++)
            {
                fld = flds[i];
                // get the value
                Object value = fld.getPersistentField().get(obj);
                // convert value to a supported sql type
                value = fld.getFieldConversion().javaToSql(value);
                // copy the sql type
                value = fld.getJdbcType().getFieldType().copy(value);
                target.put(fld.getPersistentField().getName(), value);
            }
            target.put(CLASS_NAME_STR, obj.getClass().getName());
            return target;
        }
View Full Code Here

    {
        PBCapsule capsule = new PBCapsule(pbKey, TxManagerFactory.instance().getTransaction());
        try
        {
            PersistenceBroker broker = capsule.getBroker();
            FieldDescriptor fld = broker.getClassDescriptor(this.getClass()).getAutoIncrementFields()[0];
            Integer val = (Integer) broker.serviceSequenceManager().getUniqueValue(fld);

            int result = val.intValue();
            return result;
        }
View Full Code Here

        fields[0] = obj.getClass(); // we must notice if the object class changes
        count++;

        for (int i = 0; i < fieldDescs.length; i++)
        {
            FieldDescriptor fd = fieldDescs[i];
            PersistentField f = fd.getPersistentField();
            fields[count] = f.get(obj);
            count++;
        }

        int countRefs = 0;
View Full Code Here

         * 2. register all fields of object that aren't collections or references
         */
        FieldDescriptor[] fieldDescs = mif.getFieldDescriptions();
        for(int i = 0; i < fieldDescs.length; i++)
        {
            FieldDescriptor fld = fieldDescs[i];
            // map copies of all field values
            Object value = fld.getPersistentField().get(myObj);
            // get the real sql type value
            value = fld.getFieldConversion().javaToSql(value);
            // make copy of the sql type value
            value = fld.getJdbcType().getFieldType().copy(value);
            // buffer in image the field name and the sql type value
            // wrapped by a helper class
            fieldValues.put(fld.getPersistentField().getName(), new EqualsFieldHelper(fld.getJdbcType().getFieldType(), value));
        }


        /**
         * MBAIRD
 
View Full Code Here

        }
        count++;

        for (int i = 0; i < fieldDescs.length; i++)
        {
            FieldDescriptor fd = fieldDescs[i];
            PersistentField f = fd.getPersistentField();
            f.set(obj, fields[count]);
            count++;
        }

        for (Iterator it = refDescs.iterator(); it.hasNext(); count++)
View Full Code Here

    private static Collection getExtentClasses(ClassDescriptor cld)
    {
        /**
         * 1. check if this class has a ojbConcreteClass attribute
         */
        FieldDescriptor fd = cld.getFieldDescriptorByName(ClassDescriptor.OJB_CONCRETE_CLASS);
        Collection classes = new HashSet()// use same class only once
        if (fd != null)
        {
            classes.add(cld.getClassOfObject().getName());
        }
View Full Code Here

   */
  public TreeGroup createTreeGroup() throws Exception
  {
    TreeGroup result = new TreeGroup();

    FieldDescriptor idFld = broker.getClassDescriptor(Tree.class).getFieldDescriptorByName("id");
    Integer idVal = (Integer) broker.serviceSequenceManager().getUniqueValue(idFld);

        result.setId(idVal.intValue());
    result.setData("" + result.getId());
    result.setChilds(new Vector());
View Full Code Here

  {

    Tree result = new Tree();
    try
    {
      FieldDescriptor idFld = broker.getClassDescriptor(Tree.class).getFieldDescriptorByName("id");
      Integer idVal = (Integer) broker.serviceSequenceManager().getUniqueValue(idFld);

      result.setId(idVal.intValue());
    }
    catch (PersistenceBrokerException e)
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.metadata.FieldDescriptor

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.