[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-4559) Envers AuditMetadata Generator causes java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column

Gail Badner (JIRA) noreply at atlassian.com
Mon Jan 10 23:18:05 EST 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4559?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner updated HHH-4559:
-----------------------------

    Assignee: Adam Warski

Adam, please assign this issue as appropriate.
Thanks,
Gail

> Envers AuditMetadata Generator causes java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
> ------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-4559
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4559
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: envers
>    Affects Versions: 3.5.0-Beta-2
>         Environment: Hibernate 3.5.0-Beta-2
> RDBMS: Microsoft SQL Server, version: 09.00.4230
> JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2.4
>            Reporter: Kevin Schmidt
>            Assignee: Adam Warski
>            Priority: Blocker
>         Attachments: envers_formula.patch, ExampleTestClass.java, HHH4559TestCase.java, HHH4559TestCase.java, HibernateEnversIssue-HHH-4559.zip, logForHHH4559TestCase.txt
>
>
> Dear Hibernate Team, 
>     I attempted to enable Envers for a Legacy Hibernate Application which uses hbm.xml based mapping files.  The building of the SessionFactory fails due to a class cast exception in the Envers code base.  It appears that while generating mapping data in the AuditMetadataGenerator it is assumed that a discriminator is a Column, but it can also be a Formula.  This causes a class cast exception to be thrown as is shown below (see the last cause in the exception stack trace).  I know the response is going to be attach a test case, but I am not even sure how to create a good test case.  Are there instructions on the wiki some where?  Some starting project I could use to create the test case?  In order to reproduce this issue I think it is as simple as enabling auditing for an entity which has a discriminator based on a formula instead of a column.
> [2009.11.10 09:33:32.302 XYZ] Failed to initialize due to exception.
> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.sessionFactory' defined in class path resource [com/xyz/data/spring-config-data.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not init listeners
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
> 	at com.XYZ.services.springscope.AbstractXYZSpringScopeStrategy.get(AbstractXYZSpringScopeStrategy.java:87)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
> 	at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
> 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:184)
> 	at $Proxy6.openSession(Unknown Source)
> 	at com.XYZ.data.hibernate.conversation.Conversation.<init>(Conversation.java:59)
> 	at com.XYZ.data.hibernate.conversation.ConversationManagerImpl.startConversation(ConversationManagerImpl.java:128)
> 	at com.XYZ.data.hibernate.conversation.ConversationManagerImpl.beginConversation(ConversationManagerImpl.java:110)
> 	at com.XYZ.core.initialization.AbstractInitializationThread.run(AbstractInitializationThread.java:145)
> 	at com.XYZ.services.thread.ThreadsManager$ThreadWrapper.run(ThreadsManager.java:147)
> 	at java.lang.Thread.run(Unknown Source)
> Caused by: org.hibernate.HibernateException: could not init listeners
> 	at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
> 	at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1378)
> 	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1367)
> 	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:858)
> 	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
> 	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
> 	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
> 	... 18 more
> Caused by: java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
> 	at org.hibernate.envers.configuration.metadata.MetadataTools.addColumns(MetadataTools.java:154)
> 	at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateMappingData(AuditMetadataGenerator.java:252)
> 	at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:327)
> 	at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
> 	at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
> 	at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
> 	at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:259)
> 	at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
> 	at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
> 	at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
> 	... 26 more

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list