cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sampath Uppula <SU0064...@TechMahindra.com>
Subject not able to access the properties using the Persistent Object dynamically - please help
Date Wed, 17 Oct 2012 07:43:05 GMT
Hi,

I have many persistent classes in my application and all the classes generated by cayenne
tool, one of the class is, TaskMaster.

public abstract class _TaskMaster extends CayenneDataObject {

      public static final String TASK_ACTION_PROPERTY = "taskAction";
      public static final String TASK_DEPENDENT_KEY_PROPERTY = "taskDependentKey";
      public static final String TASK_DESCRIPTION_PROPERTY = "taskDescription";
      public static final String TASK_ENTRY_CRIETERIA_PROPERTY = "taskEntryCrieteria";
      public static final String TASK_EXIT_CRIETERIA_PROPERTY = "taskExitCrieteria";
      public static final String TASK_KEY_COLUMN_PROPERTY = "taskKeyColumn";
      public static final String TASK_NAME_PROPERTY = "taskName";
      public static final String TASK_PARENT_ID_PROPERTY = "taskParentId";
      public static final String TASK_TYPE_PROPERTY = "taskType";
      public static final String TASK_CONTEXT_PROPERTY = "taskContext";
      public static final String TASK_LAYER_PROPERTY = "taskLayer";
      public static final String TASK_ROLE_PROPERTY = "taskRole";
      public static final String TASK_TRANSACTION_PROPERTY = "taskTransaction";

      public static final String ID_PK_COLUMN = "ID";

      //setter & getter methods of the preperties

}

My code is :

1).
      public static void testPersistent() throws Exception {
            ObjectContext context = DataContext.createDataContext();
            String tmpStr = "com.persistent.TaskMaster";
            Class tmpClass = Class.forName(tmpStr);

            Persistent object = (Persistent) DataObjectUtils.objectForPK(context, tmpClass,
12);

//here I am not able to fetch the values of the properties of the TaskMaster class.
//please provide the help on this.
      }

2).
                              Class tmpClass = Class.forName(tmpStr);
                              expression = ExpressionFactory.matchExp((Persistent) DataObjectUtils.objectForPK(context,
tmpClass, taskIdentifierValue));
                              expression = expression.andExp((Expression) exitCriteria.get(tmpStr));

                              tmpQuery = new SelectQuery(tmpClass, expression);
                              List<Persistent> list = context.performQuery(tmpQuery);

I am developing the strategic functionality, where the persistent class name and properties
comes from the configuration dynamically.
Based on the persistent class and properties, I need to frame the expression and query and
need to prepare the collection to display the results on JSP.

So in the above code, the dynamic class name is, "TaskMaster" once I get the persistent object
I want to fetch the values of all the properties defined in the TaskMaster class.
I don't have any clue how to do that, please throw some light on this to achieve.

Thanks,
Sampath Uppula


============================================================================================================================Disclaimer:
 This message and the information contained herein is proprietary and confidential and subject
to the Tech Mahindra policy statement, you may review the policy at <a href="http://www.techmahindra.com/Disclaimer.html">http://www.techmahindra.com/Disclaimer.html</a>
externally and <a href="http://tim.techmahindra.com/tim/disclaimer.html">http://tim.techmahindra.com/tim/disclaimer.html</a>
internally within Tech Mahindra.============================================================================================================================

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message