-->
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: Automatically trimming spaces off CHAR columns
PostPosted: Fri Jun 22, 2012 11:25 am 
Newbie

Joined: Fri Jun 22, 2012 11:17 am
Posts: 3
I'm new to JPA/Hibernate. I did some searching and couldn't find an answer to this seemingly easy problem.

I'm writing a large app that is hitting a legacy database. That database is accessed by millions and millions of lines of non-java legacy code so changing the database is not an option. The database has hundreds and hundreds of tables and thousands of columns. Unfortunately they stored their strings as CHAR(xx) data types.

We're using JPA with Hibernate as our implementation. All the Strings loaded into my entity classes have trailing spaces due to the CHAR(xx) data types in the tables. So for example instead of a first name being "John" it's "John ".

Is there an easy way to get these to be automatically trimmed? I really hate the idea of writing this into the getters of a large number of entities.

It seems like I read that some other JPA implementations automatically do this trimming. I'm hoping that there is an easy way to get Hibernate to behave this way as well.

Thanks for any advice.


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.