You could write a simple test to compare calling your setters and using reflection. Do you know the beanutils package?
This is what I have in my mind.
<java>
//TODO: track time
Map values = new HashMap();
values.put (FIELD_NAME,FIELD_VALUE);
...
for(int i=0 ; i< 1000000 ; i++)
{
Bean bean = new Bean();
BeanUtils.populate(bean,values);
}
//TODO: track time
for(int i=0 ; i< 1000000 ; i++)
{
Bean bean = new Bean();
bean.setXX(values.get(XX));
...
}
//TODO: track time
</java>Map values = new HashMap();
values.put (FIELD_NAME,FIELD_VALUE);
...
for(int i=0 ; i< 1000000 ; i++)
{
Bean bean = new Bean();
BeanUtils.populate(bean,values);
}
//TODO: track time
for(int i=0 ; i< 1000000 ; i++)
{
Bean bean = new Bean();
bean.setXX(values.get(XX));
...
}
//TODO: track time
This should give you an idea o reflection speed.
--
Leandro Rodrigo Saad Cruz
CTO - InterBusiness Technologies
db.apache.org/ojb
guara-framework.sf.net
xingu.sf.net
On 7/25/06, Sumanta Ghosh <[EMAIL PROTECTED]> wrote:
Hi,
We have started a new project where I have proposed IBATIS. But since
IBATIS uses reflection to populate result or parameters, people are raising
concerns. Now we have decided to go with either of the 2 options: -
1. Using Maps for result and parameters and then populating the
Entities from Maps (e.g. Entities will have a setAttributes(Map attrs)
method where a Entity will set its attributes from the Map) - but here the
concern is slowness of Map and also more coding, as in each Entity we have
to implement setAttributes(Map attrs) method.
2. Using Entities as result and parameters - but here concern is
usage of reflection.
Which option to go with? Please advice.
--
View this message in context: http://www.nabble.com/Usage-of-Reflection-tf1996304.html#a5479650
Sent from the iBATIS - User - Java forum at Nabble.com.
