Hibernate version: 3.2 CR5
Hi all
i'm trying to use a Result Transformer, like described in:
http://blog.hibernate.org/cgi-bin/blosx ... 006/03/17/
Here is my hibernate query:
Code:
public List<AngebotContainer> searchAngeboteNEW(final JuausAngebot angebot,
final List<Integer> allowedOrganisationIdList) {
ANGEBOT_CONSTRAINT.validate(angebot);
HibernateTemplate hibernateTemplate = new HibernateTemplate(getSessionFactory());
return (List<AngebotContainer>) hibernateTemplate.execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
Criteria criteria = session.createCriteria(JuausAngebot.class);
criteria.setResultTransformer(Transformers.aliasToBean(AngebotContainer.class));
criteria.createAlias("angebotsArt", "angebotsArt");
criteria.createAlias("organisation", "organisation");
ProjectionList pl = Projections.projectionList();
pl.add(Projections.property("angebotsArt"), "angebotsArt");
pl.add(Projections.property("organisation"), "organisation");
pl.add(Projections.property("nutzergruppe"), "nutzergruppe");
pl.add(Projections.property("mutUser"), "mutUser");
pl.add(Projections.property("mutDatum"), "mutDatum");
criteria.setProjection(pl);
if (angebot.getAngebotsArt() != null) {
criteria.add(Restrictions.eq("angebotsArt.id", angebot.getAngebotsArt().getId()));
}
//more critera
// don't return the deleted angebote
criteria.add(Restrictions.ne("status", AngebotStatus.GELOESCHT));
return criteria.list();
}
});
}
In my Manager i get the list which contains Objects Arrays. Then i'll try to cast it to a AngebotContainer and i get a class cast exception. But the the example it seems like its done the same way:
Code:
StudentDTO dto = (StudentDTO)resultWithAliasedBean.get(0);
Here is my ManagerCode which causes the exception:
Code:
List<AngebotContainer> agbListNEW = angebotDao.searchAngeboteNEW(angebotCriteria, orgIds);
AngebotContainer test = (AngebotContainer)agbListNEW.get(0);
What did i understand wrong?
thanks
angela