Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

VERSION field name is not valid hibernate

 
chen young
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

After doing some research I decided to use hibernate
The implementation and configuration was very easy and fast via maven & net beans.

The problem start when I try to run the first HQL query.
Apparently hibernate does not like the fact that version can use for field name :


java.lang.ClassCastException: org.hibernate.type.BigDecimalType cannot be cast to org.hibernate.type.VersionType
at org.hibernate.tuple.PropertyFactory.buildVersionProperty(PropertyFactory.java:84)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:168)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)


So I change the fields name to “abc” something like this:


<version name="abc" type="big_decimal">
<column name="VERSION" precision="22" scale="0" />
</version>

But then I got the following error:


org.hibernate.PropertyNotFoundException: Could not find a getter for abc in class com.cra.hbm.pojo.CMapping
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
at org.hibernate.tuple.PropertyFactory.buildVersionProperty(PropertyFactory.java:84)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:168)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)


is there any workaround for this scenario ?


Thanks

 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to use versionning/ID type with BigDecimal here? In that case floating types cannot be used for these...
 
chen young
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

I will check it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic