<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 閱讀(692) 評論(0)  編輯  收藏 所屬分類: 數據庫
    主站蜘蛛池模板: 日韩在线视频线视频免费网站| 亚洲国产夜色在线观看| 免费无毒a网站在线观看| 日本免费人成黄页在线观看视频| 亚洲精品国产成人| 精品无码免费专区毛片| 亚洲色图在线观看| 18观看免费永久视频| 亚洲国产av美女网站| 无人在线观看免费高清视频| 国产.亚洲.欧洲在线| 永久免费bbbbbb视频| 又长又大又粗又硬3p免费视频| 亚洲真人日本在线| 午夜免费啪视频在线观看| 亚洲综合激情另类小说区| 99久久这里只精品国产免费 | 亚洲成AV人片在线播放无码| 免费无码又爽又刺激网站直播| 亚洲精品私拍国产福利在线| 免免费国产AAAAA片| 国产精品亚洲片在线花蝴蝶| 国产成人精品日本亚洲专区61| 无码AV片在线观看免费| 亚洲国产综合精品中文第一| 免费在线观看一级毛片| 日日麻批免费40分钟无码| 亚洲熟妇AV一区二区三区宅男| 亚洲精品99久久久久中文字幕| 男的把j放进女人下面视频免费| jlzzjlzz亚洲jzjzjz| 亚洲国产精品成人一区| 麻豆成人久久精品二区三区免费| 亚洲综合精品第一页| 国产亚洲av片在线观看18女人| 2020因为爱你带字幕免费观看全集 | 国产成人免费福利网站| 97在线免费视频| 亚洲欧美熟妇综合久久久久 | 国产亚洲精品自在线观看| 午夜性色一区二区三区免费不卡视频|