cf9 orm unicode support

97 views
Skip to first unread message

russ

unread,
Jan 10, 2011, 6:48:27 PM1/10/11
to cf-orm-dev
i am working on an app needs unicode data storage. having some
difficulty on finding out how to setup orm or hibernate so it will
support unicode. appreciate if anyone with previous experience could
share some insights.

thanks in advance!
russell

Mark Mandel

unread,
Jan 10, 2011, 7:07:41 PM1/10/11
to cf-or...@googlegroups.com
It's usually just a datasouce setting and database config.

What DBMS are you using?

Mark


--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To post to this group, send email to cf-or...@googlegroups.com.
To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cf-orm-dev?hl=en.




--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

cf.Objective(ANZ) - Nov 18, 19 - Melbourne Australia
http://www.cfobjective.com.au

Hands-on ColdFusion ORM Training
www.ColdFusionOrmTraining.com

Russell Liu

unread,
Jan 10, 2011, 7:25:46 PM1/10/11
to cf-or...@googlegroups.com
Thanks for getting back!

I am using MS SQL server 2005 and i am relying on orm to create tables.

in my mapping component, i did use nvarchar as type to make sure that the DB table supports unicode and verified the table was created as expected.

below is my sample mapping cfc:

component persistent="true" entityname="clients" table="clients" {


property name="client_id" type="numeric" fieldType="id" generator="increment"
property name="client_name" type="string" sqltype="nvarchar(200)";
property name="client_path" type="string" sqltype="nvarchar(200)";
}

i found this article: http://blog.tremend.ro/2007/05/23/hibernate-utf-8-and-sql-server-2005/, but since it was from 2007, i wonder if there is anything done by the cf team to address orm support for unicode. 

thanks!
russ

Mark Mandel

unread,
Jan 10, 2011, 7:28:49 PM1/10/11
to cf-or...@googlegroups.com
Okay, so you have nvarchar sqltypes.... what else do you need?

Are you facing any actual issues pushing in and out UTF-8 characters?

Mark

Russell Liu

unread,
Jan 10, 2011, 7:40:58 PM1/10/11
to cf-or...@googlegroups.com
yes, that is exactly my problem.

i verified the characters were correctly encoded in my requests to insert/update data using the orm, but once data gets into the DB, the unicode data becomes garbage. i know with ms sql server, when writing sql statements to insert/update unicode data, we will have to use:

set foo=N'bar',

trying to find out if there is any orm alternative to do the same.

thanks!
russ

Mark Mandel

unread,
Jan 10, 2011, 7:52:28 PM1/10/11
to cf-or...@googlegroups.com
Two things:

In you connection string for the datasource, do you have:
useUnicode=true&characterEncoding=UTF-8

When viewing the SQL output from Hibernate with lopgSQL turned on, what do you see for inserts/updates? Is it the correct format?

Mark

Paul Hastings

unread,
Jan 11, 2011, 1:55:54 AM1/11/11
to cf-or...@googlegroups.com
On 1/11/2011 7:52 AM, Mark Mandel wrote:
> Two things:
>
> In you connection string for the datasource, do you have:
> /useUnicode=true&characterEncoding=UTF-8

isn't that for mySQL?


not 100% up to speed yet w/ORM but if it's using cfqueryparam or something
similar, make sure to check the "String format Enable High ASCII characters and
Unicode for data sources configured for non-Latin characters" box (advanced
menu) for that datasource.

Mark Mandel

unread,
Jan 11, 2011, 2:03:18 AM1/11/11
to cf-or...@googlegroups.com
I know you have to do it with mySQL, but looking through some google searches, it looks like you may need to do it for MSSQL - but I could be wrong :)

Mark


On Tue, Jan 11, 2011 at 5:55 PM, Paul Hastings <paul.h...@gmail.com> wrote:
isn't that for mySQL?



Paul Hastings

unread,
Jan 11, 2011, 3:02:33 AM1/11/11
to cf-or...@googlegroups.com
On 1/11/2011 2:03 PM, Mark Mandel wrote:
> I know you have to do it with mySQL, but looking through some google searches,
> it looks like you may need to do it for MSSQL - but I could be wrong :)

normally it's not needed w/the MS & DD drivers. jTDS i think has a
"sendStringParametersAsUnicode" parameter that's nifty to "turn unicode off" for
SELECTs that search non-unicode data (so as to avoid the sql server performance
hit).

Russell Liu

unread,
Jan 11, 2011, 8:21:09 PM1/11/11
to cf-or...@googlegroups.com
i tried both options,

adding "sendStringParametersAsUnicode" parameter didn't work for using the native ms sql driver.

checking the "String format Enable High ASCII characters and Unicode for data sources configured for non-Latin characters" box did the trick!

thanks much for the tip!

Paul Hastings

unread,
Jan 11, 2011, 8:46:24 PM1/11/11
to cf-or...@googlegroups.com
On 1/12/2011 8:21 AM, Russell Liu wrote:
> i tried both options,
>
> adding "sendStringParametersAsUnicode" parameter didn't work for using the
> native ms sql driver.

that's jTDS specific (and just in case you don't know, that's another, faster,
ms sql server JDBC driver).

Reply all
Reply to author
Forward
0 new messages