-->
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: Any Unicode SqlServer Dialect for Hibernate ver 3.3.2?
PostPosted: Fri Jan 22, 2010 11:41 am 
Newbie

Joined: Fri Jan 22, 2010 11:26 am
Posts: 3
Hi folks, I am using Hibernate version 3.3.2 to hit MS SQLServer 2008 and 2005. It turns out that commonly used SQLServerDialect is only mapping strings to varchar column in SQLServer, so unicode characters can't be stored or retrieved. I understand I could extend SQLServerDialect to map "Types.VARCHAR" to "nvarchar($l)" and solve the unicode problem. But this seems like a very common problem for lots of customers. Is Hibernate planning to provide this type of Unicode Dialect support for SQLServer? Or should I log an issue to request it? Or better, is there another simple way allowing me to write/read unicode into sqlserver through hibernate without special customization?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Any Unicode SqlServer Dialect for Hibernate ver 3.3.2?
PostPosted: Tue Mar 12, 2013 9:35 am 
Newbie

Joined: Tue Mar 12, 2013 9:33 am
Posts: 2
Code:
public class SQLServerUnicodeDialect extends org.hibernate.dialect.SQLServerDialect {
    public SQLServerUnicodeDialect() {
        super();
        registerColumnType(Types.CHAR, "nchar(1)");
        registerColumnType(Types.LONGVARCHAR, "nvarchar(max)" );
        registerColumnType(Types.VARCHAR, 4000, "nvarchar($l)");
        registerColumnType(Types.VARCHAR, "nvarchar(max)");
        registerColumnType(Types.CLOB, "nvarchar(max)" );

        registerColumnType(Types.NCHAR, "nchar(1)");
        registerColumnType(Types.LONGNVARCHAR, "nvarchar(max)");
        registerColumnType(Types.NVARCHAR, 4000, "nvarchar($l)");
        registerColumnType(Types.NVARCHAR, "nvarchar(max)");
        registerColumnType(Types.NCLOB, "nvarchar(max)");

        registerHibernateType(Types.NCHAR, StandardBasicTypes.CHARACTER.getName());
        registerHibernateType(Types.LONGNVARCHAR, StandardBasicTypes.TEXT.getName());
        registerHibernateType(Types.NVARCHAR, StandardBasicTypes.STRING.getName());
        registerHibernateType(Types.NCLOB, StandardBasicTypes.CLOB.getName() );
    }
}


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.