-->
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: Default values for not mapped columns
PostPosted: Mon Nov 08, 2004 11:30 am 
Newbie

Joined: Tue Oct 05, 2004 4:56 am
Posts: 7
Hibernate version: 2.1.6

Name and version of the database you are using: Oracle 9.2.0.5

The problem we have is that we have still some fields in the database which are not used anymore. Since they have a not-null constraint we have to populate them but we would want to hide them with our object model so that developers are no longer aware of these columns and populate them with a default value (e.g. always a space character).

Is there a way to specify a default value for a property or even a column not mapped with hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:19 pm 
Beginner
Beginner

Joined: Sun Oct 03, 2004 8:50 am
Posts: 32
Location: McLean, VA
Three things I could think of off the top of my head

These two require you to map the column.

1. During construction time set the value to something and make the getters and setters private. Then no one can call these methods but you still get the values in there.

2. Use the unsaved-value attribute on your property mapping. This only works for non-primitive types though I believe.

Or, if you can add triggers to your database you can always have them populate those columns with default values on insert.

_________________
- Chad


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.