when i tried to execute the following code:
Calendar date = new GregorianCalendar()
CalendarDate calDate = new CalendarDate();
calDate.setDate(date.getTime());
calDate.setDateStatus(CalendarDate.STATUS_AVAILABLE);
Transaction tx = hibernateSession.beginTransaction();
hibernateSession.save(calDate);
tx.commit();
i got the following to me absolutely unclear exception on the commit statement:
2003-09-12 19:09:28,094 [Thread-5] ERROR (QSEEServlet.java:125) - java.lang.ClassCastException
java.lang.ClassCastException
at net.sf.hibernate.type.ShortType.set(ShortType.java:26)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:46)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:31)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:367)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:626)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:602)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:27)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2101)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2074)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2017)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:57)
at de.sag.qsee.taskscheduler.business.AppointmentManager.generateFreeAppointmentSlots(AppointmentManager.java:420)
After going through the code and mappings for more then 2 hours (in fact i even ended up debugging hibernate) i found out that the problem was actually a mapping mistake on a class in a collection i filtered 2 methods before.
the code for the filtering was this:
workingdays = hibernateSession.filter(
technician.getWorkingDays(),
"where this.weekDay = ?",
new Short((short) date.get(Calendar.DAY_OF_WEEK)), Hibernate.SHORT);
and the problem was that in db and mapping the weekDay was a short but in the class it was defined as an int.
isn't there a way to check on errors like this earlier on for example while parsing the mappings or while actually running the filter instead of throwing it much later on, when you run the first transaction on this session?
|