Results 1 to 2 of 2
  1. #1
    niteangell21 is offline Member
    Join Date
    Sep 2010
    Posts
    40
    Rep Power
    0

    Default 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!

  2. #2
    niteangell21 is offline Member
    Join Date
    Sep 2010
    Posts
    40
    Rep Power
    0

    Default Re: hibernate creates white spaces on db when saving emtpy strings

    Quote Originally Posted by niteangell21 View Post
    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.

Similar Threads

  1. Creates multiple log files
    By bikashlama in forum New To Java
    Replies: 3
    Last Post: 12-27-2011, 07:09 AM
  2. Replies: 2
    Last Post: 06-29-2011, 10:08 AM
  3. When the compiler creates the variable?
    By hitesh_public in forum New To Java
    Replies: 14
    Last Post: 08-17-2010, 11:21 AM
  4. How to display a String that contains more than one white spaces
    By thachun in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 09-27-2009, 10:16 AM
  5. Saving Blob through Hibernate
    By Ed in forum JDBC
    Replies: 2
    Last Post: 01-05-2009, 06:03 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •