hibernate creates white spaces on db when saving emtpy strings
Guys,
I am new to hibernate and still learning. In our application, I noticed that every time I save an empty string into a field using hibernate, it creates a white space in the db column.The hibernate method used is saveOrUpdate().It passes an user object as argument which has a fax number field which is empty string(""). But when saved, the db fax number column has a white space. I am using sybase db and the fax is type varchar.If I pass in null instead of empty string, it works fine. Not sure where the white space coming from for empty strings. I did find some articles regarding db padding, but here the type is varchar and it shouldn't do any padding, right? So how fix this?
Any advice would be greatly appreciated.
Thanks!
Re: hibernate creates white spaces on db when saving emtpy strings
Quote:
Originally Posted by
niteangell21
Guys,
I am new to hibernate and still learning. In our application, I noticed that every time I save an empty string into a field using hibernate, it creates a white space in the db column.The hibernate method used is saveOrUpdate().It passes an user object as argument which has a fax number field which is empty string(""). But when saved, the db fax number column has a white space. I am using sybase db and the fax is type varchar.If I pass in null instead of empty string, it works fine. Not sure where the white space coming from for empty strings. I did find some articles regarding db padding, but here the type is varchar and it shouldn't do any padding, right? So how fix this?
Any advice would be greatly appreciated.
Thanks!
I found it. Its the database padding that adds the white space and nothing to do with hibernate.