-->
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: What is the best way to set default value for DO property?
PostPosted: Mon Aug 15, 2005 10:41 pm 
Newbie

Joined: Fri Apr 08, 2005 6:28 pm
Posts: 17
Location: US
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0.5

Hello!

What is the best (i.e. recommended) way to set defaults for Data Object properties?

I can think about the following two ways:

1. Specify defaults in he schema (DDL), map all objects with dynamic-insert="true", and refresh() the object after save() (or saveOrUpdate() )
2. Initialize properties with their default values programmatically (in class declaration or constructors)

#1 is ugly and requires querying after each insert
#2 results in the newly constructed data objects having properties set to values other then "unsaved-value". Will it break anything?

Is there a more elegant way to set property defaults?

Thank you,
Dmitri


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 1:42 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Default values must be the same in application and in database. Default values to maintained in database to have valid model and you need to maintain default values in application to avoid reload. It is not a problem in my practice, JAVA language defaults make sence in most of cases and do not need to be maintained.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 12:03 pm 
Newbie

Joined: Fri Apr 08, 2005 6:28 pm
Posts: 17
Location: US
baliukas ,

thank you.

Dmitri


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.