-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Question about "version" attribute names in MySQL
PostPosted: Mon Mar 17, 2008 4:21 pm 
Newbie

Joined: Mon Mar 17, 2008 3:51 pm
Posts: 8
Location: Colorado Springs, CO
Hi,

I'm running 3.2.6.ga and was mapping in a legacy MySQL DB (MySQL 5.0.37-community-nt) using hibernatetool. The table had an attribute called "version" on it. I noticed when I tried to run it I got the following exception:

Code:
Caused by: java.lang.ClassCastException: org.hibernate.type.StringType
   at org.hibernate.tuple.PropertyFactory.buildVersionProperty(PropertyFactory.java:84)
   at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:170)
   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:1300)


I looked in my mapping file and noticed it had produced:

Code:
        <version name="version" type="string">
            <column name="version" length="32" />
        </version>


when it should have produced:

Code:
        <property name="version" type="string">
            <column name="version" length="32" not-null="true"/>
        </property>


So, I changed it to an attribute and ran my code and it seems to work just fine. Is this a configuration issue on my end or a bug?

Thanks,

Ben


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 18, 2008 1:50 am 
Newbie

Joined: Sat Mar 15, 2008 3:54 am
Posts: 6
It's definitely not a bug. Just because "version" has special meaning in hibernate( to control concurrency ).
I don't know what tool you use to "produced" the mapping file but, I think it mistakenly treat that version property as version. Just like if you have a id property, it will by default be treated as id.
That's why I prefer hand craft mapping files :) software can't beat human brain.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.