Castle activerecord has released the latest version 2.1. It also supports more databases and fixes many bugs. Currently, the project uses the earliest version 1.0, I encountered a problem during database migration. For example, when migrating data from MSSQLServer to SQLite, version 1.0 is not supported, which makes me suffer. Therefore, after downloading version 2.1 and testing, there were a lot of inexplicable problems, which added a lot of difficulty to the porting work. This process once doubted whether AR was a correct choice, after a failed attempt, we finally got the result. The record is as follows:
1. configuration changes
Original Configuration:
Code Properties. Add ( " Hibernate. proxyfactory. factory_class " , " Nhibernate. bytecode. Castle. proxyfactoryfactory, Nhibernate. bytecode. Castle " );
Properties. Add ( " Hibernate. Connection. driver_class " , " Nhib.pdf. Driver. sqlclientdriver " );
Properties. Add ( " Hibernate. Dialect " , " Nhib.pdf. dialect. mssql2000dialect " );
Properties. Add ( " Hibernate. Connection. Provider " , " Nhib.pdf. Connection. driverconnectionprovider " );
Properties. Add ( " Hibernate. Connection. connection_string " , " Data Source =.; initial catalog = databasename; Integrated Security = sspi " );
New Configuration:
Code Properties. Add ( " Proxyfactory. factory_class " , " Nhibernate. bytecode. Castle. proxyfactoryfactory, Nhibernate. bytecode. Castle " );
Properties. Add ( " Connection. driver_class " , " Nhib.pdf. Driver. sqlclientdriver " );
Properties. Add ( " Dialect " , " Nhib.pdf. dialect. mssql2005dialect " );
Properties. Add ( " Connection. Provider " , " Nhib.pdf. Connection. driverconnectionprovider " );
Properties. Add ( " Connection. connection_string " , " Data Source =.; initial catalog = databasename; Integrated Security = sspi " );
The new configuration method is changed: 1 is to cancel the "hibernate" prefix, 2 is to add the "proxyfactory" settings.
2. If you migrate data from sqlserver to PostgreSQL, you may encounter an exception that does not support auto-increment ID columns. The reasons are as follows:
PostgreSQL has many versions. Different versions must use different "dialects". PostgreSQL dialects include the following:
Postgresqldialect
Postgresql81dialect
Postgresql82dialect
The database I use is 8.4, and everything is OK in postgresql82dialect.
In addition, Castle ar's support for creating data tables based on the domain model in nhib.pdf facilitates my work, but it does not support incremental updates yet. xpo is a bit of a concern when I think of it, we hope that the Nhibernate Team will continue to work hard to bring me back to the market.