-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate code generation adds unexpected @Version?
PostPosted: Mon Feb 01, 2010 8:24 am 
Newbie

Joined: Mon Feb 01, 2010 8:04 am
Posts: 2
Hello all,

I'm using eclipse 3.5 and hibernate tools v3.2.4 to generate JPA annotated entites from a SQL Server 2008 database using MS sqljdbc4.jar JDBC driver.

For some reason on one column hibernate code generation allways generates @Version annotation:

Code:
   @Version
   @Temporal(TemporalType.DATE)
   @Column(name = "Timestamp", nullable = false)
   public Date getTimestamp() {
      return this.timestamp;
   }


Column "Timestamp" is designed with SQL Server 2008 type "date" on db server side.

I also have a type-mapping defined for this column in my hibernate.reveng.xml file:

Code:
   <table catalog="catalog" schema="dbo" name="Table" class="db.Table">
      <primary-key>
         <generator class="identity"></generator>
      </primary-key>
      <column name="Timestamp" jdbc-type="NVARCHAR" type="date"></column>
   </table>



Is there a way to prevent generation of @Version attribute ?

Why does it get generated in the first place (am I doing something wrong) ?


Regards,

Mario


Top
 Profile  
 
 Post subject: Re: Hibernate code generation adds unexpected @Version?
PostPosted: Tue Feb 02, 2010 5:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
disable auto optimistic locking detection and it won't look at it.

You can also customize the detection in a custom reverse engineering strategy if you wish.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Hibernate code generation adds unexpected @Version?
PostPosted: Tue Feb 02, 2010 3:58 pm 
Newbie

Joined: Mon Feb 01, 2010 8:04 am
Posts: 2
It works great - thank you very much!

Regards,

Mario


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.