Hi,
I've got two methods (setter and getter) for a property in my bean that is called
'EquipmentId' (setEquipmentId, getEquipmentId) i.e. PersistentFieldPropertyImpl is
used for Introspection. Using the repository.xml to map it like:
"
<field-descriptor id="3"
name="EquipmentId"
column="EQNUM"
jdbc-type="VARCHAR" indexed="true" nullable="false"
/>
"
The code snippet in PersistentFieldPropertyImpl.findPropertyDescriptor(Class aClass,
String aPropertyName) is doing the following.
"
info = Introspector.getBeanInfo(aClass);
pd = info.getPropertyDescriptors();
for (int i = 0; i < pd.length; i++)
{
if (pd[i].getName().equals(aPropertyName))
{
descriptor = pd[i];
break;
}
}
"
the getName returns the property of the bean but the first letter is Lower Case! is it
by convension or is it a bug since setEquipmentId and getEquipmentId would yield a
property named EquipmentId not equipmentId. The more stranger is when all letters in
the setter and getter is UPPERCASE it would correctly return the property name i.e. if
setEQUIPMENTID and getEQUIPMENTID is specified the p[i].getName() will return
EQUIPMENTID!
I've changed the code snippet to:
"
String csWritePropertyName = "set" + aPropertyName;
for (int i = 0; i < pd.length; i++)
{
Method meth = pd[i].getWriteMethod();
if (null != meth)
{
if (true == meth.getName().equals(csWritePropertyName))
{
descriptor = pd[i];
break;
}
}
}
if (pd[i].getName().equals(aPropertyName))
{
descriptor = pd[i];
break;
}
"
since Method.getName() correctly displays the method name (as always). I've never used
the Introspector but I think this is a strange behaviour or?
Many Regards,
Mario
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]