The moose likes Object Relational Mapping and the fly likes Leading zero's being trimmed off Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Leading zero Watch "Leading zero New topic
Author

Leading zero's being trimmed off

Carlos Juan
Greenhorn

Joined: Jul 17, 2006
Posts: 5
I am using Oracle as backend database. Here is a issue I am facing and need some help.


I have a database table with datatype VARCHAR2(25)

In my hbm.xml I have the following:


Now if I have a value 00875. When a data is saved leading zero's are some how trimmed off and only 875 is saved in the table.
How can I make to insert 00875 without trimming off any leading or trailing zero's. Any help is appreciated.

Thanks
Carlos Juan
Greenhorn

Joined: Jul 17, 2006
Posts: 5
I figured out the root cause it's not the hibernate. I am using JAXB and any time I get a value starting with leading zero's i.e. 00785 as I have defined nonNegativeInteger in my xsd. As can't change the xsd so probably will explicitly check if the returned value is of some specific length if not then append the leading zero's, or if someone have a better solution will be more then happy to look at. Thanks
 
 
subject: Leading zero's being trimmed off
 
Threads others viewed
sample code discrimination feature.
Could not parse mapping document from resource PojoTestTable.hbm.xml
Help Please?
Error while trying to get data from Master-Detail tables
Problem with read-write cache
developer file tools