<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

    I found out today that MS Sql server seems to handle Unicode in a very special way. Instead of having some support a database or table level, each Unicode column have to be created as “national”. That is be either nchar, nvarchar or ntext.

    Ms SQL Server 2005 seems to go one step further by announcing future deprecation for ntext, text and image types.

    From Sql Server 2005 notes:

    ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.”

    When working with Hibernate it seems there is no dialect to handle Unicode integration properly. You have to get down and write a custom dialect that maps to the new data types.

    /**
    * Unicode support in SQL Server
    *
    * @author icocan
    */
    public class UnicodeSQLServerDialect extends SQLServerDialect {

    public UnicodeSQLServerDialect() {
    super();

    // Use Unicode Characters
    registerColumnType(Types.VARCHAR, 255, "nvarchar($l)");
    registerColumnType(Types.CHAR, "nchar(1)");
    registerColumnType(Types.CLOB, "nvarchar(max)");

    // Microsoft SQL Server 2000 supports bigint and bit
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.BIT, "bit");
    }
    }
    read more ...

    You have to write your own SQLServerDialect class, it looks something like this:
    publicclassSQLServerNativeDialectextendsSQLServerDialect{
         publicSQLServerNativeDialect(){
             super();
             registerColumnType(Types.VARCHAR,"nvarchar($l)");
             registerColumnType(Types.CLOB,"nvarchar(max)");
         }

        publicString getTypeName(int code,int length,int precision,int scale)throwsHibernateException{
            if(code !=2005){
                returnsuper.getTypeName(code, length, precision, scale);
            }else{
                return"ntext";
            }
        }
    }

    This class maps Hibernate's types to SQL types, so the class will map the nvarchar(max) SQL Data Type to Hibernate's CLOB data type.

    The getTypeName method is used to return "ntext" when Hibernate asks about the data type with code 2005 (which looks like it's the nvarchar(max) data type).

    Finally, you need to change your hibernate persistence dialect to this new SQLServerDialect class, which allows hibernate to translate data types into SQL data types.


    posted on 2010-11-29 18:49 seal 閱讀(685) 評論(0)  編輯  收藏 所屬分類: 數據庫
    主站蜘蛛池模板: 成年在线观看免费人视频草莓| 亚洲福利在线视频| 女人张开腿给人桶免费视频| 日本免费一区二区三区四区五六区| 精品国产污污免费网站入口| 污污视频免费观看网站| 亚洲精品无码专区在线播放| 亚洲国产精华液2020| 精品国产日韩久久亚洲| 亚洲成a人片在线观看中文动漫| 亚洲不卡中文字幕无码| 亚洲综合另类小说色区| 亚洲日韩欧洲无码av夜夜摸| 女人被免费视频网站| 1a级毛片免费观看| 一区二区三区四区免费视频 | 亚洲AV无码一区二区三区国产| 成人黄软件网18免费下载成人黄18免费视频| 我的小后妈韩剧在线看免费高清版| 免费无码又爽又刺激聊天APP| 日本高清免费不卡在线| 亚洲精品国产成人影院| 精品国产综合成人亚洲区| 久久丫精品国产亚洲av| 亚洲综合色一区二区三区| 处破女第一次亚洲18分钟| 国产免费人成视频尤勿视频| 日韩免费在线观看视频| 999国内精品永久免费视频| 日韩免费一区二区三区| 国产亚洲美女精品久久久| 久久精品国产亚洲av麻豆色欲 | 2022中文字字幕久亚洲| 亚洲AV本道一区二区三区四区| 亚洲乱码中文论理电影| 亚洲AV日韩AV永久无码色欲| 国产亚洲精品免费视频播放| 4455永久在线观免费看| 免费观看国产小粉嫩喷水| 亚洲av无码国产精品色午夜字幕 | 免费人妻精品一区二区三区|