You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Sampath Uppula <SU...@TechMahindra.com> on 2012/10/17 09:43:05 UTC
not able to access the properties using the Persistent Object
dynamically - please help
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.============================================================================================================================
RE: not able to access the properties using the Persistent Object
dynamically - please help
Posted by Sampath Uppula <SU...@TechMahindra.com>.
Thank you very much for the reply, it is working fine with DataObject.
Thanks,
Sampath Uppula|eConvergence,BT-15|Tech Mahindra
------------------------------------------------------------------------------
S1-W-5572, West Wing, Block-1, Hinjewadi-Phase III, Pune 411 057, INDIA
S Office: +91 20 42250000 Extn: 250879 | Cell: +91 9730745043
Email: SU0064323@techmahindra.com
www.techmahindra.com
-----Original Message-----
From: Andrus Adamchik [mailto:andrus@objectstyle.org]
Sent: Wednesday, October 17, 2012 5:50 PM
To: user@cayenne.apache.org
Subject: Re: not able to access the properties using the Persistent Object dynamically - please help
Hi there,
I suggest to cast to DataObject (instead of Persistent) and use DataObject API to read/write properties:
DataObject object = (DataObject) DataObjectUtils.objectForPK(context, tmpClass, 12);
object.readProperty(someProperty);
object.writeProperty(someProperty, someValue);
Andrus
On Oct 17, 2012, at 10:43 AM, Sampath Uppula <SU...@TechMahindra.com> wrote:
> 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.============================================================================================================================
============================================================================================================================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.============================================================================================================================
Re: not able to access the properties using the Persistent Object dynamically - please help
Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi there,
I suggest to cast to DataObject (instead of Persistent) and use DataObject API to read/write properties:
DataObject object = (DataObject) DataObjectUtils.objectForPK(context, tmpClass, 12);
object.readProperty(someProperty);
object.writeProperty(someProperty, someValue);
Andrus
On Oct 17, 2012, at 10:43 AM, Sampath Uppula <SU...@TechMahindra.com> wrote:
> 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.============================================================================================================================