zoukankan      html  css  js  c++  java
  • Castle ActiveRcord 升级及数据库迁移

    Castle ActiveRecord 已经发布了最新的2.1版本,同时也支持了更多的数据库和修正了很多的Bug,目前项目里使用的却还是最早的1.0版本,在数据库迁移时遇到了问题,比如从MSSqlServer 迁移到SqLite 时,1.0版本就不支持,让我好不痛苦。因此,下载了2.1版本,测试,却得到很多莫名其妙的问题,为移植工作增加了不少的难度,此过程曾一度怀疑选择AR是否是一个正确的选择,经过了一段失败的尝试,终于有了结果。记录如下:

    1、配置的改变

     原配置:

    代码
                    properties.Add("hibernate.proxyfactory.factory_class""NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
                    properties.Add(
    "hibernate.connection.driver_class""NHibernate.Driver.SqlClientDriver");
                    properties.Add(
    "hibernate.dialect""NHibernate.Dialect.MsSql2000Dialect");
                    properties.Add(
    "hibernate.connection.provider""NHibernate.Connection.DriverConnectionProvider");
                    properties.Add(
    "hibernate.connection.connection_string""Data Source=.;Initial Catalog=DataBaseName;Integrated Security=SSPI");

    新的配置:

    代码
    properties.Add("proxyfactory.factory_class""NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
                    properties.Add(
    "connection.driver_class""NHibernate.Driver.SqlClientDriver");
                    properties.Add(
    "dialect""NHibernate.Dialect.MsSql2005Dialect");
                    properties.Add(
    "connection.provider""NHibernate.Connection.DriverConnectionProvider");
                    properties.Add(
    "connection.connection_string""Data Source=.;Initial Catalog=DataBaseName;Integrated Security=SSPI");

    新的配置方法的改变:1是取消了“hibernate”的前缀,2是增加了“proxyfactory”的设置。 

     2.如果是从SqlServer 迁移到 PostgreSQL时,可能遇到:不支持自动增长ID列的异常,原因如下:

    PostgreSQL有好多版本,不同版本要使用不的 “方言”,PostgreSQL方言有以下几种:

    PostgreSQLDialect 

    PostgreSQL81Dialect 

    PostgreSQL82Dialect 

    我使用的数据库是8.4的,在 PostgreSQL82Dialect 一切OK。

    另外,Castle AR在nHibernate基础上支持根据领域模型创建数据表的工作方式给我的工作带来便利,但目前还不支持增量更新,一想到这里就有点怀念XPO,希望nHibernate小组继续努力,让我等也能乘势而上。

  • 相关阅读:
    MyCAT常用分片规则之分片枚举
    MySQL参数
    CentOS 7下MySQL服务启动失败的解决思路
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
    MyCAT实现MySQL的读写分离
    搭建Spark的单机版集群
    如何部署Icinga服务端
    MyCAT简易入门
    如何部署Icinga客户端
  • 原文地址:https://www.cnblogs.com/yyj/p/1704047.html
Copyright © 2011-2022 走看看