-->
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.  [ 2 posts ] 
Author Message
 Post subject: Ampersand in named parameter value
PostPosted: Mon Jul 25, 2005 7:03 pm 
Newbie

Joined: Mon Jul 25, 2005 6:42 pm
Posts: 5
I am having problems with a query that has an ampersand in a named parameter value. My parameter string is 'R&D', but the debug log only shows binding 'R' to parameter: 2. I therefore do not get back the record that is in my database.

Code:
Code:
String queryStr1 = "FROM Projectdetail pd" +
                   " WHERE pd.employeeId = :emp" +
                   "   AND pd.activity = :act ";
Query query = session.createQuery(queryStr1)
                     .setString("emp", employeeId)
                     .setString("act", activity);
List results = query.list();



I call the function with
Code:
employeeId = "C11"
and
Code:
activity = "R&D"

The log shows:

Code:
2005-07-25 16:31:33,312 DEBUG [org.hibernate.type.StringType] - binding 'R' to parameter: 2
2005-07-25 16:31:33,359 DEBUG [org.hibernate.type.StringType] - binding 'C11' to parameter: 1


Everything works fine if I do not have the ampersand in the activity variable.

Setup details:
Win XP
mySQL 4.1.10
JDBC connector: 3.1.10 (Also downgraded to 3.1.7 with no change)
Hibernate 3.0.5

I would appreciate suggestions on how to fix this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 7:58 pm 
Newbie

Joined: Mon Jul 25, 2005 6:42 pm
Posts: 5
Nevermind.

It looks like I have problems upstream from the point I posted. I found that the activity variable actually held "R" not the expected "R&D". My problem is elsewhere.

Sorry about the false alarm--I'll bet you are used to them, but I am sorry.


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