-->
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.  [ 3 posts ] 
Author Message
 Post subject: Quesion about get() method in Session class
PostPosted: Tue Mar 28, 2006 7:15 am 
Newbie

Joined: Tue Mar 28, 2006 6:57 am
Posts: 6
There is a table whose primary key is of type CHAR(3) and there are some records in this table having less than three characters in primary key column. Here is the example.
Table name: REF_CCY
Primary Key: ccy_cd

There are two records.
1. "AUD"
2. "XX"

When I query the first record like this
Code:
Session session;
session.get(RefCcy.class,"AUD")

I can get what I what.

However, when I query the second record
Code:
session.get(RefCcy.class,"XX")

I can get nothing except a null pointer!

If I change the type of CHAR(3) to VARCHAR2(3), this problem would arise. Could you please tell me what I should do with the type CHAR?Many thanks![/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 11:04 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
I too hate the CHAR data types

http://www.hibernate.org/90.html

edit: The oracle CHAR padding stuff is towards the bottom

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Last edited by kochcp on Tue Mar 28, 2006 11:11 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 11:05 am 
Newbie

Joined: Tue Nov 15, 2005 4:21 am
Posts: 11
CHAR fields are padded with spaces. Use a VARCHAR if you don't want padding, otherwise you have to search for "XX " (note the trailing space)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.