[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3002) database field name 'version' causes ClassCastException while building session factory

Chin Hsu (JIRA) noreply at atlassian.com
Thu Feb 7 12:53:33 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3002?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29478 ] 

Chin Hsu commented on HHH-3002:
-------------------------------

I don't know if you use reverse engineering tool to generate the hbm.xml but I did and have the exact same exception trace.  for a database table with a column named version, the generated hbm will have the field defined in a version element:

        <version  name="version" type="string">
            <column name="VERSION" length="20" />
        </version>

when it should be:

        <property  name="version" type="string">
            <column name="VERSION" length="20" />
        </property>

manually fix the hbm.xml file solves the problem.  I think this maybe a bug on the reverse engineering tool?  

> database field name 'version' causes ClassCastException while building session factory
> --------------------------------------------------------------------------------------
>
>                 Key: HHH-3002
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3002
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.5
>         Environment: Hibernate 3.2.5, Java 1.6.0_03, MySQL 5.0.41 
>            Reporter: Patrick Burke
>         Attachments: out.hib4
>
>
> When a database table contains a field named 'version', like his one: 
> DROP TABLE IF EXISTS `tester`.`software_package`;
> CREATE TABLE  `tester`.`software_package` (
>   `software_id` int(11) NOT NULL auto_increment,
>   `version` varchar(100) default NULL,
>   `name` varchar(100) default NULL,
>   `root_file_id` int(11) default NULL,
>   PRIMARY KEY  (`software_id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
> The following error is thrown:
> [java] Initial SessionFactory creation failed.java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType
>      [java] Exception in thread "main" java.lang.ExceptionInInitializerError
>      [java] 	at util.HibernateUtil.<clinit>(Unknown Source)
>      [java] 	at events.EventManager.listNodes(Unknown Source)
>      [java] 	at events.EventManager.main(Unknown Source)
>      [java] Caused by: java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType
>      [java] 	at org.hibernate.tuple.PropertyFactory.buildVersionProperty(PropertyFactory.java:84)
>      [java] 	at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:168)
>      [java] 	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
>      [java] 	at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
>      [java] 	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
>      [java] 	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
>      [java] 	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
>      [java] 	... 3 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