java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType

In my case, I generated entity from DB and some entities column name has "version". Generator for this names add "@Version" annotation, but this column type is String - for @Version annotation unacceptable


This types of problem occurs

  • if there are column name as "version" of "VARCHAR" (string) type in any table, means in hibernate "property" becomes "version" and "type" becomes "string", like-

    in .hbm.xml file

    <version name="xyz" type="string">
        <column name="xyz" length="30" not-null="true" />
    </version>
    
  • if there are any missing getter or setter method for a particular attribute.

  • if there are mismatch between .hbm.xml file and POJO class file.


I have checked several times all the mapping classes. Finally, the problem came from a mapping class which had not the proper type for an attribute... :( Thank you for your responses

Tags:

Java

Hibernate