-->
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.  [ 1 post ] 
Author Message
 Post subject: hbm2java generates dbtimestamp -> not compilable
PostPosted: Thu Aug 11, 2011 6:12 pm 
Newbie

Joined: Thu Aug 11, 2011 2:49 pm
Posts: 1
Hi all,

I am pretty new to hibernate, so please excuse if my questions were answered before, although I tried my best to search for the answers to problem...

I use the classic hbm.xml approach and having problems with the hibernate versioning possibilities. The MySQL database has a timestamp column called t_update that is automatically updated. I want to use this column for the versioning. I have defined the following hbm.xml

Code:
<hibernate-mapping>
    <class name="de.littlejoes.hibernate.model.Thing"  table="game" catalog="betdata" >
        <id name="id" type="java.lang.Long">
            <column name="id" />
            <generator class="identity" />
        </id>
        <timestamp name="lastUpdate" column="t_update" source="db" generated="always" />
        ...
   </class>
</hibernate-mapping>


The hbm2java tools runs through, but it produces code that can't be compiled. Here is the created java code:

Code:
public class Thing implements java.io.Serializable {

   private Long id;
   private dbtimestamp lastUpdate;
   
...

   public dbtimestamp getLastUpdate() {
      return this.lastUpdate;
   }

   public void setLastUpdate(dbtimestamp lastUpdate) {
      this.lastUpdate = lastUpdate;
   }



The problem is the type "dbtimestamp", which is not recognized by the java compiler. Eclipse suggests a change it to DbTimestampType. If I change the code as suggested my program does not run either (A runtime exception IllegalArgumentException occurred while calling setter of de.littlejoes.hibernate.model.Thing.lastUpdate stops the show...).

I feel, that I miss some obvious point about the usage of timestamps for versioning. I need to use timestamps because the database has other non-hibernate clients that also change data rows, so the approach to use hibernate/JVM generated version numbers would not work for me.

Can anyone help me finding my error(s)? if you need more information, please ask and I see to post all required information.

Cheers,
Jay


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

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.