-->
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: Using dataserver generated datetime values on insert/update
PostPosted: Fri Sep 10, 2004 6:13 pm 
Newbie

Joined: Fri Sep 10, 2004 6:05 pm
Posts: 1
[b]Hibernate version: 2.1.6[/b]

[b]Name and version of the database you are using: Sybase 12.5[/b]

Hi,

I have a need to have my dataserver (Sybase 12.5) generate datetime values on insert / update of data. So, for example if I have an entity similar to:

MyEntity {
int a;
Date b;
}

I would expect b to be null, and populated with the result of a Sybase getdate() on insert and (optionally) on an update too. I've looked at the documentation for "timestamp" and "version" in the documentation but these don't appear to do exactly what I need.

I have also seen that "property" allows an attribute called "formula" that I can set to getdate(). However the result of this arbitrary SQL is *not* written to the database on insert or an update.

Any help would be greatly appreciated,

Scot


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 11, 2004 12:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You would need to map the column as essentially read-only (insert="false" update="false") and then use a trigger/default in the db to set the value.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 3:40 pm 
Newbie

Joined: Wed Oct 06, 2004 3:31 pm
Posts: 1
Location: Costa Rica
steve wrote:
You would need to map the column as essentially read-only (insert="false" update="false") and then use a trigger/default in the db to set the value.


What happens when that column is part of the primary key? I'm working with a legacy system in DB2, and I have that problem. The table has a composite ID with a Timestamp column being part of it. The problem is, you can set "insert=false" in a "property" but you can't do that in a "key-property", even when the INSERT can be done without setting the value for the Timestamp beacause it has a default value set. Thanks in advance for your help.


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.