-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Unclear exception
PostPosted: Fri Sep 12, 2003 1:59 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 9:50 am
Posts: 34
Location: Weiden Opf. / Germany
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?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 2:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
nope. No Way.


How would I check the type of this:


" ... where MY_SQL_FUNCTION(foo.bar) = :value"


Hibernate, just like JDBC does not do type checking of query parameters. It is just Too Hard.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2003 4:38 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 9:50 am
Posts: 34
Location: Weiden Opf. / Germany
hehe. well it was worth a try ;)

but actually it's not type checking of the query parameter, because the query parameters were correct.

what didn't match the db was the mapping...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2003 4:44 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 9:50 am
Posts: 34
Location: Weiden Opf. / Germany
sorry, let me correct this.

the mapping matched the db as the query parameter did, but the type of the attribute in the class was wrong.

and what i'm really surprised about is the the filtering of the wrong class worked fine and i only got an execption when i ran a completely seperate transaction on a different class much later on.

if you don't know how hibernate works exactly you would never expect that to happen.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.