I'm creating a home brew ORM since our web server does not have Hibernate. I call the orm specifying the class to return the results as:
class AwareScoringData
{
public String groupCode = null;
public String contactId = null;
public String systemMode = null;
@SuppressWarnings("unused")
public AwareScoringData() {}
}
AwareScoringData scoring = queryOne(conn, AwareScoringData.class,
"SELECT contactid, group_code, system_mode FROM scoring WHERE scoring_id = ?", minScoringId);
In the ORM code I then use reflection to instantiate the class with:
try
{
Constructor<T> constructor = clazz.getConstructor();
if (constructor == null)
{
final String message = "No public constructor for " + clazz.getName();
staticLogger.error(message);
throw new IllegalArgumentException(message);
}
constructor.setAccessible(true);
result = constructor.newInstance();
}
catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e)
Problem is that clazz.getConstructor() throws NoSuchMethodException.
If I inject a clazz.getConstructors() in the code, I see only a constructor with parameters:
public com.lifeinnov.aware.setup_account.screens.AwareStudentData$1ScoringData(com.lifeinnov.aware.setup_account.screens.AwareStudentData)
Where did this constructor come from? Why?
Aucun commentaire:
Enregistrer un commentaire