-->
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.  [ 7 posts ] 
Author Message
 Post subject: oakward behaivour with session.find()
PostPosted: Sun Oct 26, 2003 5:42 pm 
Newbie

Joined: Tue Oct 14, 2003 2:32 pm
Posts: 11
Hi guys I'm new to Hibernate and I will appreciate some help with some awkward behavior I just can't fix

I am using Oracle 9i and working with a table named users with a pk
char(16)
the thing is that when I request a List with one user with the next statements:

String id="Administrator";
List objects=session.find("from User as user where user.userId=?",id,Hibernate.STRING);

I get nothing, however if I change it to:

String id=" \'Administrator\' "; //look the \'
List objects=session.find("from User as user where user.userId="+id);

I do get the user but the most interesting thing is that if I change the id to meet the size of the table field like this;

String id="Administrator "; // look the blanks
List objects=session.find("from User as user where user.userId=?",id,Hibernate.STRING);

I do get the user. I am sure there is something I am doing wrong
and I can adjust my code to work like this but it seems awkward to me

some ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 5:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
change from CHAR to VARCHAR2.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 9:31 pm 
Newbie

Joined: Tue Oct 14, 2003 2:32 pm
Posts: 11
gavin wrote:
change from CHAR to VARCHAR2.


thanks gavin I changed it but didn't work. Maybe it has something to do with Oracle?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 9:34 pm 
Newbie

Joined: Mon Oct 20, 2003 3:03 pm
Posts: 13
was 'Administrator' fat-fingered into oracle?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 8:01 am 
Newbie

Joined: Tue Oct 14, 2003 2:32 pm
Posts: 11
kbrown wrote:
was 'Administrator' fat-fingered into oracle?


if you mean done with Administrator role then yes it was


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 1:43 pm 
Newbie

Joined: Tue Oct 14, 2003 2:32 pm
Posts: 11
gavin wrote:
change from CHAR to VARCHAR2.


My mistake gavin you were right, I changed the first time to VARCHAR insted of VARCHAR2, now I fixed that and is working

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 3:15 pm 
Newbie

Joined: Thu Jan 29, 2004 7:02 pm
Posts: 3
Location: Houston
I have the same problem. Environment is:
Oracle 9.2
Hibernate 2.1.1

In my case the column is CHAR(30).

The column in the database contains, say 'fred', padded out to 30 characters with spaces.

This works:
String name = "fred";
queues = session.find("select queue " +
" from Queue as queue " +
"where queue.name = '" + name + "'");

This does not:
String name = "fred";
queues = session.find("select queue " +
" from Queue as queue " +
"where queue.name = ?",
name, Hibernate.STRING);

If I go ahead and pad name out with spaces, then the parameter query will work.

In my case, changing the column definition is not an option. In that case, is there any way to have the parameter query work with an un-padded name ?


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