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)