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