-->
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.  [ 1 post ] 
Author Message
 Post subject: How to deal with padded fields in legacy database
PostPosted: Tue May 09, 2006 11:56 pm 
Newbie

Joined: Sun Apr 23, 2006 1:23 am
Posts: 3
I believe the following situation is a good candidate for using a Custom Type (org.hibernate.UserType) or a Hibnerate Interceptor, but I'm not sure and I'm not sure which is most appropriate...

I'm working on converting a legacy software system to a Java web application. The legacy software pads several text fields with trailing space characters for the length of the field. Even worse, there is a foreign key field (trans_id) that a VARCHAR of 9 and the legacy software puts 9 space characters in it instead of making it NULL when there is no related foreign key value/record.

So, I'd like to be able to map this in Hibernate, but to tell Hibernate to treat a tran_id value of all spaces as NULL (i.e. don't try to load the associated record). There are other fields, such as the user_id that is used for logging in, that I'd just like to trim().

I believe that I could use a Custom Type for trimming the fields, but I'm not sure if that will work for the trans_id foreign key field that I want to set to NULL if it is all spaces. I would like to map it as a one-to-many relationship in the mapping file so that the related WorkflowTransaction record for a given trans_id will be loaded along with the primary record (Alert table). My Alert object has to have a trans_id right now instead of a WorkflowTransaction object as an attribute since Hibernate chokes on the space characters because there is no WorkflowTransaction record in the database with a key value of 9 space characters.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.