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.  [ 4 posts ] 
Author Message
 Post subject: How to represent Char(n) in Hibernate without space problem
PostPosted: Mon Sep 25, 2006 8:00 am 
Newbie

Joined: Mon Sep 25, 2006 7:42 am
Posts: 7
Hibernate version: 3.0

Name and version of the database :Oracle 10g


General Question ::

How can i trim String data for using it with Char in Oracle
eg: I have a table with Char(5) and data less than 5 chars then i am getting spaces in place of rest of the characters., which i dont want.,
How can overcome this problem without changing the Database?

_________________
Never Give Up


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 9:26 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
you might need to define it as VARCHAR2(5)

Check a similar thread.
http://forum.hibernate.org/viewtopic.ph ... light=char


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 12:05 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
You need to build and use a custom UserType in your Hibernate mapping. That way, the db stays as char(n), the POJO uses String and the custom UserType does the conversion between the two. See http://www.hibernate.org/388.html in the wiki for an example.

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 26, 2006 12:22 am 
Newbie

Joined: Mon Sep 25, 2006 7:42 am
Posts: 7
CWitherow wrote:
You need to build and use a custom UserType in your Hibernate mapping. That way, the db stays as char(n), the POJO uses String and the custom UserType does the conversion between the two. See http://www.hibernate.org/388.html in the wiki for an example.

Curtis ...


Thanks Curtis...I will see if this works....

_________________
Never Give Up


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

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.