NHibernate 2.0.0 Alpha 1 悄悄地发布了


NHibernate 2.0 Alpha 1
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
转载请注明此处,谢谢!

Tag标签: NHibernate
posted @ 2008-03-31 17:11 李永京 阅读(3691) 评论(39)  编辑 收藏 所属分类: NHibernate

  回复  引用  查看    
#1楼 2008-03-31 17:21 | Anders Cui      
好消息!
  回复  引用  查看    
#2楼 2008-03-31 17:38 | RicCC      
不错,添加不少比较重要的特性
  回复  引用  查看    
#3楼 [楼主]2008-03-31 17:38 | 李永京      
@Anders Cui
呵呵,第一时间知道,就写篇文章发到首页了,把这消息分享给更多的人!
  回复  引用  查看    
#4楼 [楼主]2008-03-31 17:40 | 李永京      
@RicCC
是的啊,我想到正式版会更出色,可以同LINQ同媲美了。或许比LINQ更好!
  回复  引用  查看    
#5楼 2008-03-31 17:51 | RicCC      
@李永京
NH跟LINQ不太好比较的,要说是用方便上如果NH能将hibernate3的HQL实现早点导入过来可能会更好
官方的特性列表里面说2.0会提供LINQ支持,文章的列表里面好像没有,是这个Alpha版本还没有实现吗
  回复  引用  查看    
#6楼 2008-03-31 17:51 | 生鱼片      
不知道LINQ,NHibernate有什么区别,有了LINQ,不知道 NHibernate的路会怎么样?
  回复  引用  查看    
#7楼 [楼主]2008-03-31 17:59 | 李永京      
@RicCC
都是ORM。LINQ有LINQ to SQL,NHibernate有NHibernate to LINQ。比较的是效率,开发速率等等了。
  回复  引用  查看    
#8楼 [楼主]2008-03-31 18:00 | 李永京      
@生鱼片
呵呵,这就要看NHibernate开发的情况了,不过从过去看来,一直是挺优秀的!
  回复  引用  查看    
#9楼 [楼主]2008-03-31 18:05 | 李永京      
@RicCC
是啊,看似没有LINQ支持,晚上看看源代码。。。
  回复  引用  查看    
#10楼 2008-03-31 18:28 | Zhongkeruanjian      
是啊,支持NH
  回复  引用  查看    
#11楼 2008-03-31 18:28 | 代码乱了      
HQL 上的变化不小啊。呵呵
  回复  引用  查看    
#12楼 [楼主]2008-03-31 19:07 | 李永京      
@代码乱了
确实!正式版我想更强大了
  回复  引用  查看    
#13楼 2008-03-31 19:13 | brightwang      
关注啊,现在的项目用的就是NH,希望能达到在JAVA世界里的水平
  回复  引用  查看    
#14楼 [楼主]2008-03-31 19:19 | 李永京      
@brightwang
呵呵,用VS2008体验一把!
  回复  引用  查看    
#15楼 2008-03-31 21:47 | 黎波      
期待!
  回复  引用  查看    
#16楼 2008-03-31 21:59 | Kevin Li      
光一下
  回复  引用  查看    
#17楼 [楼主]2008-03-31 22:04 | 李永京      
@黎波
o(∩_∩)o...
  回复  引用  查看    
#18楼 [楼主]2008-03-31 22:06 | 李永京      
@Kevin Li
光顾一下??o(∩_∩)o...
  回复  引用  查看    
#19楼 2008-04-01 00:07 | Leem      
2008写的?难道这个版本必须要有framework 3以上支持?
  回复  引用  查看    
#20楼 2008-04-01 03:32 | Jeffrey Zhao      
不是已经有人在做LINQ to NHibernate了吗?
  回复  引用  查看    
#21楼 2008-04-01 09:24 | 冰隼      
关注,现在还在用1.2.0。如果Release了,会考虑迁移的。
  回复  引用    
#22楼 2008-04-01 09:45 | caodaiming [未注册用户]
有没有NStruts啊,这个也可以啊,在小公司也可以快速的开发啊,对了其是MVC就可以说成是NStruts啊,
  回复  引用  查看    
#23楼 2008-04-01 11:08 | 小瑞克      
我觉得这个东西很麻烦,好多配置文件,大概用codesmith生成比较方便,可惜偶不会。。。。
  回复  引用  查看    
#24楼 [楼主]2008-04-01 12:08 | 李永京      
@Leem
不需要,只是把代码移植到2008上的,大多数还有2005项目。
  回复  引用  查看    
#25楼 [楼主]2008-04-01 12:13 | 李永京      
  回复  引用  查看    
#26楼 [楼主]2008-04-01 12:14 | 李永京      
@小瑞克
配置是有些麻烦。以后我试试模板
  回复  引用  查看    
#27楼 [楼主]2008-04-01 12:15 | 李永京      
@caodaiming
不清楚这个,观望中~~~
  回复  引用  查看    
#28楼 [楼主]2008-04-01 12:15 | 李永京      
@冰隼
现在体验一下!到正式版相信会更加出色!
  回复  引用  查看    
#29楼 2008-06-26 00:07 | 昊子      
无法访问sourceforge,其他人有没有出现过这个问题
  回复  引用  查看    
#30楼 [楼主]2008-06-26 00:24 | 李永京      
@昊子
经过月光对路由的测试,经过电信骨干网的某个路由器时,访问被阻拦,因此相信这是电信的所为,中国电信对于专业技术类型网站的屏蔽令人感到不解,上一次的误封还是发生在2006年,这一次不知道又是为了什么原因。
当然,希望SourceForge的无法访问不是因为这个项目的问题,然而不可否认的是,对于SourceForge这样一个庞大的软件开源项目的屏蔽,会对中国的软件发展产生严重的阻碍,影响中国的科技发展和进步。
  回复  引用  查看    
#31楼 2008-06-27 01:02 | 昊子      
另外发现hibernate.org本身对NH的文档不很重视,下载链接也还是1.2 GA,完全没有提到2.0 beta。

不知道是不是可以理解为NH本身没有团队支持
  回复  引用  查看    
#32楼 [楼主]2008-06-27 14:15 | 李永京      
@昊子
这是测试版的,内部测试的,我想到正式版之后才可以公开发布的。
  回复  引用    
#33楼 2008-07-01 09:05 | gakaki [未注册用户]
有 必要开一个Nhiberate Sample
专题 每个特性都值得介绍
  回复  引用  查看    
#34楼 [楼主]2008-07-01 09:24 | 李永京      
@gakaki
不必了吧,这些特性只有在使用过程中才能慢慢体会。
  回复  引用  查看    
#35楼 2008-07-04 13:29 | 毁于随      
我有一个问题不清楚,也是我值不值得研究它的一个主要的问题,比如A类与B类关联,B类与C类关联.如果在不采用延迟加载的时候,如果要一起把这相关的三个类都加载了,是用一个SQL语句(使用关联),还是要使用三条语句加载(如果是1对多的关系,那调用的次数要呈几何级增加)?我还没有研究NHibernate,希望楼主能给我讲解一下,谢谢.
  回复  引用    
#36楼 2008-07-06 13:09 | piaoxue [未注册用户]
to 35楼

建议你先看看书,孙卫琴的 精通hibernate。

aspx@hotmail.com
  回复  引用  查看    
#37楼 2008-07-07 08:32 | 毁于随      
就是没有什么时间看书,所以才来请教的.
  回复  引用  查看    
#38楼 [楼主]2008-07-11 20:51 | 李永京      
@piaoxue
谢谢你的回复,一直没有时间上网
  回复  引用  查看    
#39楼 [楼主]2008-07-11 20:54 | 李永京      
@毁于随
你可以先看看源码中的例子,可以很快入门/这个问题在NH中可以很好的解决。提供了映射关系支持/

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  博客园首页

  新闻频道

  社区

  小组

  博问

  网摘

  闪存

  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-04-10 21:50 编辑过


相关链接: