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