-->
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: Issue with GenerationTiming.ALWAYS
PostPosted: Sun Aug 10, 2014 2:31 pm 
Newbie

Joined: Sun Aug 10, 2014 2:19 pm
Posts: 2
I'm using the following code for a generated date column. It works for inserts, but not update. Any ideas?

Code:
@ValueGenerationType(generatedBy = FunctionCreationUpdateValueGeneration.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface FunctionCreationUpdateTimestamp {
}


Code:
public class FunctionCreationUpdateValueGeneration implements AnnotationValueGeneration<FunctionCreationUpdateTimestamp> {

   @Override
   public String getDatabaseGeneratedReferencedColumnValue() {
      return "SYSDATE";
   }

   @Override
   public GenerationTiming getGenerationTiming() {
      return GenerationTiming.ALWAYS;
   }

   @Override
   public ValueGenerator<?> getValueGenerator() {
      return null;
   }

   @Override
   public boolean referenceColumnInSql() {
      return true;
   }

   @Override
   public void initialize(FunctionCreationUpdateTimestamp arg0, Class<?> arg1) {}

}


Code:
@FunctionCreationUpdateTimestamp
@Column(name="update_date", insertable=false, updatable=false)
@Temporal(value=TemporalType.TIMESTAMP)
private Date lastUpdated;


Top
 Profile  
 
 Post subject: Re: Issue with GenerationTiming.ALWAYS
PostPosted: Sun Aug 10, 2014 2:41 pm 
Newbie

Joined: Sun Aug 10, 2014 2:19 pm
Posts: 2
To be more clear: the value is generating on inserts. When I update my entity the column does not refresh with a newly generated value; it retains the inserted value instead.. I want it to generate a new value on every update.


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.