I have class NEMgmtInfoC which extends NEMgmtInfo.
In the mapping NEMgmtInfo has polymorphism=implicit.
The following code throws ClassCastExeption on the line in bold:
Code:
public NEMgmtInfo[] getAllDevices() throws DAOException {
Query q = null;
List newList = null;
try {
q =
sess.getPersistentSession().createQuery(
"from com.db.device.NEMgmtInfo as mgmt");
newList = q.list();
} catch (HibernateException e) {
throw new DAOException(e);
}
NEMgmtInfoC[] devices = new NEMgmtInfoC[newList.size()];
for (int i = 0; i < newList.size(); ++i) {
[b]devices[i] = (NEMgmtInfoC) newList.get(i);[/b] }
return devices;
}
Bassically, I want the query to give me NEMgmtInfoC objects.
Please help.