-->
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: How to use a Timestamp as the Identifier
PostPosted: Tue Jan 03, 2012 12:50 pm 
Newbie

Joined: Tue Jan 03, 2012 12:45 pm
Posts: 4
I am trying to create a mapping in hibernate that has a <id> that
1) is a Timestamp (yyyy/mm/dd.hh.mm.ss.sss) (not a DateTime)
2) using a MYSQL database
3) where I provide the Timestamp value using my getters and setters and is not automaticly assigned by the JVM or DB.
4) that will not change when I update the record in the DB.

I am using:
1) MYSQL 5.2.26
2) Hibernate 3

How should I change the mapping (hbm.xml) so that it stops changing the Timestamp value when a update occurs. I only what the timestamp value assigned when writing a new record and from that point forward it should not change.
How should I change the mapping (hbm.xml) so that I get the microseconds because currently I only get data in MYSQL in the following format yyyy/mm/dd.hh.mm.ss. I wan/need to micro seconds because I can generate more than 1 record per second.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class name="com.microfirst.drink.request.beans.FloorConfigurations" table="BVODFCMP">
        <id name="fcStamp" type="java.sql.Timestamp">
            <column name="FCSTAMP" />
         <generator class="assigned"/>
        </id>
       <property name="fcConfigName" type="string"              column="FCCFGNAME" length="20" />
        <property name="fcBar"        type="string"              column="FCBAR"     length="20" />
        <property name="fcMapName"    type="string"              column="FCMAPNAME" length="20" />
        <property name="fcBevZone"    type="string"              column="FCBEVZONE" length="10" />
        <property name="fcStatus"     type="string"              column="FCSTATUS"  length="01" />
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: How to use a Timestamp as the Identifier
PostPosted: Wed Jan 04, 2012 3:29 pm 
Newbie

Joined: Tue Jan 03, 2012 12:45 pm
Posts: 4
Solutions for item
4) I'm not sure how to change this in the mapping but when the table was created (for MYSQL) by hibernate it created the Timestamp field with a default definitions as "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP". I don't know how to change my HBM.XML file to not use that default definition so I just changed ALTERED the table in MYSQL.

So when I update a record it is not changing the TIMESTAMP field value with a new current TIMESTAMP.
If anyone can tell me how to change the mapping to not set the default defintions to "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" I'd appreciate it.

thx.


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.