-->
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: create <timestamp> attribute in mapping file
PostPosted: Wed Apr 19, 2006 4:13 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
Hello all

i'm trying to

Does anybody know how i can generate a timestamp attribute in my mapping file like that:

Code:
<timestamp column="DMUTDAT" name="mutDatum" />


At the moment it's defined as follwoing in the reverse engineering file:

Code:
<column name="DMUTDAT" jdbc-type='' property="mutDat" />


but this results in a normal property in the mapping file:

Code:
<property name="mutDat" type="timestamp">
            <column name="DMUTDAT" length="11" not-null="true" />
        </property>


Any ideas?

regards
Angela


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 19, 2006 8:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not controllable in in reveng.xml (yet), but a custom strategy can do it:

Code:
public class YourRevEngStrategy extends DelegatingReverseEngineeringStrategy {

public YoirRevEngStrategy(ReverseEngineeringStratregy re) {
  super(re);
}

   public String getOptimisticLockColumnName(TableIdentifier identifier) {
                  if("theTable".equals(identifier.getName())) {
                       return "DMUTDAT";
                  } else {
         return super.getOptimisticLockColumnName(identifier);
                 }
   }
}


you can also choose to implement useColumnForOptimisticLock instead, but that is up to how you like to decide what the column is.

note that to have it be a timestamp the type of column should be something that is compatible with a timpestamp (date,timestamp,etc)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 19, 2006 8:35 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
thanks, this works great! :-)

regards
angela


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.