• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Default Value to Property

 
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.
 
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • 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
 
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic