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: Set all the fields of a column to a value
PostPosted: Fri Sep 03, 2010 6:37 am 
Newbie

Joined: Fri Sep 03, 2010 6:33 am
Posts: 1
Hi to all.

Is there a mode to set all the field of a column to a specified value?

thanks


Top
 Profile  
 
 Post subject: Re: Set all the fields of a column to a value
PostPosted: Fri Sep 03, 2010 11:08 am 
Beginner
Beginner

Joined: Fri Nov 13, 2009 4:05 pm
Posts: 30
Depends.

If you're talking about for new records you insert into your data store, you could define a @PreInsert method on your entity object and set the fields accordingly with their default values if no values were specified when the object was instantiated.

If you're talking about for existing records, you could define a @PreUpdate method that checks the existence of a value for the specified columns of interest and if no value exists, set it accordingly. With this approach, it would require your code to load each entity from the datastore and run an update on the entity for this naturally.

Typically if I need to do a mass change however like this, I typically do not do it in the program code but rather do it manually using data scripts that are a part of the deployment process of the application.


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.