I have a function retrieveObjectsByAttribute
that takes fieldName
and value as an argument. I have to return all objects from the database associated with the declaring class of fieldName
.
public abstract Object[] retrieveObjectsByAttribute(String fieldName, Object value)
I have to apply the SQL query as given below to retrieve objects from the database.
Select * from Table where fieldName = queryValue
My question is how can I find the declaring class if I only know the field name. The Class name is mandatory for mapping to the required table, as in ClassName->TableName
I searched on the web what i find is that declaring class can be find by Field object . For example if i have filed object queryField i can find its declaring class.
Class c= queryField.getDeclaringClass();
May be there is some way to find field object from field name.
Aucun commentaire:
Enregistrer un commentaire