-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to persist a virtual variable
PostPosted: Fri Mar 11, 2005 7:29 pm 
Newbie

Joined: Fri Mar 11, 2005 7:22 pm
Posts: 10
I'm pretty new to this whole hibernate bit.. and I was wondering if this is possible. I would like to do the opposite of a derived property (a formula in the xml).
Lets say I have a class with two strings: FirstName, LastName
However in the database, I would like to save it as FirstName +" " +LastName. AND.. i do not want to have a variable in the class. Ie i don't want a field called FullName (that holds the first name and last name). It will be in the database only, so I can search on that name.

So on an insert, and on an update the field will have to be regenerated and then persisted.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 8:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I can't imagine a really good solution for this - some crazy hack with UserTypes/PropertyAccessors might work.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 8:40 pm 
Newbie

Joined: Fri Mar 11, 2005 7:22 pm
Posts: 10
one option that I don't like, is to actually carry that variable FullName in the Class.
then on the onSave, or onUpdate I would generate that value to be saved in the database. using normal hibernate persistance mappings.

I don't really need to have "Full name" in the class, I just need it in the database to do searching easily.

Any other ideas?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.