• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Default Value to Property

 
Lakshmi Natarajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Our application needs to update a default value to a property suppose it was supplied or set. This can be done by defining default in DDL, but we cannot change the databse. We need to set this value through xml as this default value might change in future. Is there any provision in hbm file to set default value for a property.
 
Ankit Garg
Sheriff
Posts: 9578
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look here...
 
Lakshmi Natarajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit,

visited the site but the information would not be useful for me. The <meta> tag default value is used while generating the POJO class from hbm file(the POJO class generated with the default value set in setter method of the property) and does not set default value for the property for exisiting POJO class
 
Benjamin Winterberg
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at Hibernate EventListeners: http://docs.jboss.org/hibernate/stable/core/reference/en/html/events.html#objectstate-events

You could check if the property is null or empty after the entity has been loaded by hibernate and in that case set your default value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic