Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / November 2005

Tip: Looking for answers? Try searching our database.

Hibernate / MS SQL / Unicode

Thread view: 
JScoobyCed - 22 Nov 2005 10:39 GMT
Hi,

    I have a web-apps that sends unicode data to my servlet. I can save it
ot he MS SQL server and when I read it using JDBC client (Squirrel), I
can see the unicode correctly in the DB.
I use Hibernate to read/write to the DB.
I Hibernate reference docs, I didn't find anything about unicode values.
The funny thing is I can save correctly.... but when I try to query it
doesn't work.
A simple query like

session.createQuery("from User where username='xxxxxx'");

( where 'xxxxx' is a unicode String)
it returns nothing.
I triied to add a capital "N":

session.createQuery("from User where username=N'xxxxxx'");

which shows a Hibernate error ( "unexpected token '??????'");

Any idea as how I can write a "where" clause with Hibernate with unicode
values?

Thank you.

Signature

JSC

JScoobyCed - 22 Nov 2005 11:22 GMT
> Hi,
>
[quoted text clipped - 11 lines]
> ( where 'xxxxx' is a unicode String)
> it returns nothing.

Ok, found the solution...

Have to use "Criteria"
Criteria criter = session.createCriteria(User.class);
criter = criter.add(Restrictions.eq("username", usern));
List list = criter.list();

Signature

JSC

Tim Van Wassenhove - 22 Nov 2005 12:04 GMT
>> Hi,
>>
[quoted text clipped - 18 lines]
> criter = criter.add(Restrictions.eq("username", usern));
> List list = criter.list();

I'v got the feeling if you use a prepared statement that it will work
too.

Signature

Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.