I have a problem trying to read the contents in my peakperiod list. The error I have received is java.lang.object cannot be cast to java.lang.String.
Are there any possible workaround for this problem as I am using java 1.6?
Delegate.java
List peakPeriod = new ArrayList();
try{
peakPeriod = Dao.retrievePeakPeriod("2017");
for (Iterator i=peakPeriod.iterator(); i.hasNext(); {
System.out.println("Peak Periods:"+(String)i.next());
}
catch(Exception e){ System.out.println("Error:"+e);}
Dao.java
public List retrievePeakPeriod(String year) throws DataAccessException;
DaoImpl.java
public List retrievePeakPeriod(String year) throws DataAccessException {
List list = getHibernateTemplate().find("select cal.startdate,cal.enddate from Calendar cal " +
"where to_char(cal.startdate,'yyyy') = ?",
new Object[] { year },
new Type[] { Hibernate.STRING });
return list;
}