-->
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: Options for an unmapped property having a default value
PostPosted: Tue Apr 01, 2008 10:39 pm 
Newbie

Joined: Sun Feb 13, 2005 11:48 pm
Posts: 4
Location: Sydney, Australia
Hi,

I have a hibernate managed class 'Foo' that has a boolean flag on it, unfortunately this boolean flag is not persisted or present in the database.

However, any Foo object that is returned from the database should have this flag set to true.

This is rather easy to fix in that I can define the default constructor like the following:
Code:
public Foo()
{
   this.flag = true;
}

However, doing this will undermine the default logic of the Foo class and possibly undermine any client code that is using this default constructor and are unaware that they need to set the boolean flag (previously it was false); so I would like to stick clear of this option.

Are there any options via hibernates configuration that allow me to set a default for this value?

Thanks in advance,

Justin
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 10:52 pm 
Newbie

Joined: Sun Feb 13, 2005 11:48 pm
Posts: 4
Location: Sydney, Australia
Looks like I already have my solution.

Sorry for the noise!

I will just use an interceptor :)

http://www.hibernate.org/hib_docs/core/ ... terceptors


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.