-->
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.  [ 3 posts ] 
Author Message
 Post subject: type="calendar_date" throws ClassCastException in
PostPosted: Fri May 09, 2008 11:11 am 
Newbie

Joined: Fri May 02, 2008 10:07 am
Posts: 9
Hibernate version:3.1.2

We have an existing app working on Oracle & it needs to work on SQLServer as well.
When we do the changes detailed below we get a ClassCastException from tomcat at startup.

Any ideas please ?

date fields in the mapping files were previously set up as type="calendar" sql-type="date" as follows:

Code:
<version name="lastUpdated" type="calendar">
         <meta attribute="use-in-tostring">true</meta>
         <meta attribute="use-in-equals">true</meta>
         <column name="LAST_UPD" sql-type="date" not-null="true" />
</version>


This would set the column type to 'DATE' whatever the dialect was.

In order for the db script to produce the correct code dependent on the dialect
we have had to drop sql-type and set type='calendar_date' as follows:

Code:
<version name="lastUpdated" type="calendar_date">
         <meta attribute="use-in-tostring">true</meta>
         <meta attribute="use-in-equals">true</meta>
         <column name="LAST_UPD" not-null="true" />
</version>


However when we start tomcat we get the following ClassCastException:

Code:
09-05-2008 16:01:37 [main] ERROR - Context initialization failed
.......
Initialization of bean failed; nested exception is java.lang.ClassCastException: org.hibernate.type.CalendarDateType
java.lang.ClassCastException: org.hibernate.type.CalendarDateType
   at org.hibernate.tuple.PropertyFactory.buildVersionProperty(PropertyFactory.java:83)
   at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:157)
   at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
   at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
   at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:825)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:751)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)


Top
 Profile  
 
 Post subject: Still stuck ...
PostPosted: Mon May 12, 2008 4:14 am 
Newbie

Joined: Fri May 02, 2008 10:07 am
Posts: 9
Hi all,

I am still stuck.

Am I being a newb or is there a real problem ?

Thx.
Bill


Top
 Profile  
 
 Post subject: CalendarDateType does not implement VersionType
PostPosted: Mon May 12, 2008 5:38 am 
Newbie

Joined: Fri May 02, 2008 10:07 am
Posts: 9
Before anyone slams me for using a date field as a version this is legacy code and I am chanfing it to a numeric field with a sequence.

But it looks like I may have found the problem.

CalendarTypeimplements VersionType.

CalendardateType does not.

Is this a bug ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.