
NHibernate 2.0
NHibernate源于非常优秀的基于Java的Hibernate关系型持久化工具。可是从2007年11月26日发布的1.2.1GA版本不是很好的支持VS2008。今天负责NHibernate开发的Ayende Rahien发布了NHibernate 2.0.0 Alpha 1,我们可以从这里下载,相信不久正式版会更好,先下载尝鲜一下。
下载看看源代码,其中很多代码都是用VS2008写的。并附了两个例子。
下面列表列出了一些改进:
新特性:
- Add join mapping element to map one class to several tables
- <union> tables and <union-subclass> inheritance strategy
- HQL functions 'current_timestamp', 'str' and 'locate' for PostgreSQL dialect
- VetoInterceptor - Cancel Calls to Delete, Update, Insert via the IInterceptor Interface
- Using constants in select clause of HQL
- Added [ Table per subclass, using a discriminator ] Support to Nhibernate
- Added support for paging in sub queries.
- Auto discovery of types in custom SQL queries
- Added OnPreLoad & OnPostLoad Lifecycle Events
- Added ThreadStaticSessionContext
- Added <on-delete> tag to <key>
- Added foreign-key="none" since the Parent have not-found="ignore". (not relevant to SQL Server)
- Added DetachedQuery
- ExecuteUpdate support for native SQL queries
- From Hibernate:
- Ported Actions, Events and Listeners
- Ported StatelessSession
- Ported CacheMode
- Ported Statistics
- Ported QueryPlan
- Ported ResultSetWrapper
- Ported Structured/Unstructured cache
- Ported SchemaUpdate
- Ported Hibernate.UserTypes
- Ported Hibernate.Mapping
- Ported Hibernate.Type
- Ported EntityKey
- Ported CollectionKey
- Ported TypedValue
- Ported SQLExceptionConverter
- Ported Session Context
- Ported CascadingAction
Breaking changes:
- Changed NHibernate.Expression namespace to NHibernate.Criterion
- Changed NHiberante.Property namespace to NHiberante.Properties
- No AutoFlush outside a transaction - Database transactions are never optional, all communication with a database has to occur inside a transaction, no matter if you read or write data.
- <nhibernate> section is ignored, using <hibernate-configuration> section (note that they have different XML formats)
- Configuration values are no longer prefixed by "hibernate.", if before you would specify "hibernate.dialect", now you specify just "dialect"
- IInterceptor changed to match the Hibernate 3.2 Interceptor - interface changed
- Will perform validation on all named queries at initialization time, and throw if any is not valid.
- NHibernate will return long for count(*) queries on SQL Server
- SaveOrUpdateCopy return a new instance of the entity without change the original.
- INamingStrategy interface changed
- NHibernate.Search - Moved Index/Store attributes to the Attributes namespace
- Changes to IType, IEntityPersister, IVersionType - of interest only to people who did crazy stuff with NHibernate.
- <formula> must contain parenthesis when needed
- IBatcher interface change
Fixed bugs:
- Fixing bug with HQL queries on map with formula.
- Fixed exception when the <idbag> has a <composite-element> inside; inside which, has a <many-to-one>
- Multi criteria doesn't support paging on dialects that doesn't support limiting the query size using SQL.
- Fixed an issue with limit string in MsSql2005 dialect sorting incorrectly on machines with multiple processors
- Fixed an issue with getting NullReferenceException when using SimpleSubqueryExpression within another subexpression
- Fixed Null Reference Exception when deleting a <list> that has holes in it.
- Fixed duplicate column name on complex joins of similar tables
- Fixed MultiQuery force to use parameter in all queries
- Fixed concat function fails when a parameter contains a comma, and using MaxResults
- Fixed failure with Formula when using the paging on MSSQL 2005 dialect
- Fixed PersistentEnumType incorrectly assumes enum types have zero-value defined
- Fixed SetMaxResults() returns one less row when SetFirstResult() is not used
- Fixed Bug in GetLimitString for SQL Server 2005 when ordering by aggregates
- Fixed SessionImpl.EnableFilter returns wrong filter if already enabled
- Fixed Generated Id does not work for MySQL
- Fixed one-to-one can never be lazy
- Fixed FOR UPDATE statements not generated for pessimistic locking
改进:
- Added Guid support for Postgre Dialect
- Added support for comments in queries
- Added Merge and Persist to ISession
- Support IFF for SQL Server
- IdBag now work with Identity columns
- Multi Criteria now uses the Result Transformer
- Handling key-many-to-one && not-found
- Can now specify that a class is abstract in the mapping.
Guidance:
- Prefer to use the Restrictions instead of the Expression class for defining Criteria queries.
Child projects:
- Added NHibernate.Validator
- Added NHibernate.Shards
- NHibernate.Search updated match to Hibernate Search 3.0
标准API:
- Allow Inspection, Traversal, Cloning and Transformation for ICriteria and DetachedCriteria
- Introduced CriteriaTransformer class
- GetCriteriaByPath, GetCriteriaByAlias
- Added DetachedCriteria.For<T>
- Added Multi Criteria
- Projections can now pass parameters to the generated SQL statement.
- Added support for calling Sql Functions (HQL concept) from projections (Criteria).
- Added ConstantProjection
- Added CastProjection
- Can use IProjection as a parameter to ICriterion
Better validation for proxies:
- Now supports checking for internal fields as well
- Updated Castle.DynamicProxy2.dll to have better support for .NET 2.0 SP1
SQL Lite:
- Support for multi query and multi criteria
- Supporting subselects and limits
- Allowed DROP TABLE IF EXISTS semantics
PostgreSQL (Npgsql):
- Enable Multi Query support for PostgreSQL
FireBird:
- Much better overall support
Batching:
- Changed logging to make it clearer that all commands are send to the database in a single batch.
- AbstractBatcher now use the Interceptor to allow the user intercept and change an SQL before it's preparation
Error handling:
- Better error message on exception in getting values in Int32Type
- Better error message when using a subquery that contains a reference to non existing property
- Throws a more meaningful exception when calling UniqueResult<T>() with a value type and the query returns null.
- Overall better error handling
- Better debug logs
Refactoring:
- Major refactoring internally to use generic collections instead of the non generic types.
- Major refactoring to the configuration and the parsing of hbm files.
Factories:
- Added ProxyFactoryFactory
- Added BatchingBatcherFactory
作者:李永京(YJingLee's Blog)
出处:http://lyj.cnblogs.com
转载请注明此处,谢谢!
posted @ 2008-03-31 17:11
李永京 阅读(3680)
评论(39) 编辑 收藏 所属分类:
NHibernate