Re: Hibernate / MS SQL / Unicode



JScoobyCed wrote:
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.

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();

--
JSC
.



Relevant Pages

  • Re: Hibernate / MS SQL / Unicode
    ... >> I have a web-apps that sends unicode data to my servlet. ... >> I Hibernate reference docs, I didn't find anything about unicode values. ... but when I try to query it ... > Have to use "Criteria" ...
    (comp.lang.java.databases)
  • Re: Query output is always in UNICODE... need ANSI ... Help?
    ... > I'm using XP_Sendmail stored procedure to run a query and mail the ... > UNICODE and the application that subsequently consumes the attachment ... > unmodified attachment in ANSI format makes the application all happy ...
    (microsoft.public.sqlserver.programming)
  • Re: Query output is always in UNICODE... need ANSI ... Help?
    ... > I'm using XP_Sendmail stored procedure to run a query and mail the ... > UNICODE and the application that subsequently consumes the attachment ... > unmodified attachment in ANSI format makes the application all happy ...
    (microsoft.public.sqlserver)
  • Re: convert unicode to ansi
    ... If I understand correctly you are having problem sending unicode query from ... You might try using NCHAR function to create queries which ... Research also the UNICODE function which is the reverse of NCHAR. ... > by using PHP queries: ...
    (microsoft.public.sqlserver.programming)
  • Query output is always in UNICODE... need ANSI ... Help?
    ... I'm using XP_Sendmail stored procedure to run a query and mail the ... UNICODE and the application that subsequently consumes the attachment ... unmodified attachment in ANSI format makes the application all happy ...
    (microsoft.public.sqlserver.programming)