Question

What kinds of considerations are there for migrating an application from NHibernate 1.2 to 2.0? What are breaking changes vs. recommended changes?

Are there mapping issues?

Was it helpful?

Solution

Breaking changes in NHibernate 2.0

If you have good test coverage it's busywork.

Edit: We upgraded this morning. There is nothing major. You have to Flush() the session after you delete. The Expression namespace got renamed to Criterion. All these are covered in the link above. Mappings need no change. It's quite transparent. Oh, and transactions everywhere, but you were probably doing that already.

By the way, here's an interesting look at the changes: http://codebetter.com/blogs/patricksmacchia/archive/2008/08/26/nhibernate-2-0-changes-overview.aspx

OTHER TIPS

I found the answer here:

http://blog.domaindotnet.com/2008/08/24/nhibernate-20-gold-released-must-wait-for-linq-to-nhibernate/

gold release 2.0.0.GA

BREAKING CHANGES from NH1.2.1GA to NH2.0.0

  • Infrastructure

  • Compile time

    • NHibernate.Expression namespace was renamed to NHibernate.Criterion
    • IInterceptor have additional methods. (IsUnsaved was renamed IsTransient)
    • INamingStrategy
    • IType
    • IEntityPersister
    • IVersionType
    • IBatcher
    • IUserCollectionType
    • IEnhancedUserType
    • IPropertyAccessor
    • ValueTypeType renamed to PrimitiveType
  • Possible Breaking Changes for external frameworks

  • Various classes were moved between namespaces
  • Various classes have been renamed (to match Hibernate 3.2 names)
  • ISession interface have additional methods
  • ICacheProvider
  • ICriterion
  • CriteriaQueryTranslator

  • Initialization time

    • <nhibernate> section, in App.config, is no longer supported and will be ignored. Configuration schema for configuration file and App.config is now identical, and the App.config section name is: <hibernate-configuration>
    • <hibernate-configuration> have a different schema and all properties names are cheked
    • configuration properties are no longer prefixed by “hibernate.”, if before you would specify “hibernate.dialect”, now you specify just “dialect”
    • All named queries will be validated at initialization time, an exception will be thrown if any is not valid (can be disabled if needed)
    • Stricter checks for proxying classes (all public methods must be virtual)

  • Run time

    • SaveOrUpdateCopy() returns a new instance of the entity without changing the original
    • AutoFlush will not occur outside a transaction - Database transactions are never optional, all communication with the database must occur inside a transaction, whatever you read or write data.
    • NHibernate will return long for count(*) queries on SQL Server
    • <formula> must contain parenthesis when needed
    • These HQL function names may cause conflict in your HQL reserved names are:
      • substring
      • locate
      • trim
      • length
      • bit_length
      • coalesce
      • nullif
      • abs
      • mod
      • sqrt
      • upper
      • lower
      • cast
      • extract
      • concat
      • current_timestamp
      • sysdate
      • second
      • minute
      • hour
      • day
      • month
      • year
      • str
    • <any> when meta-type=”class” the persistent type is a string containing the Class.FullName
      • In order to set a parameter in a query you must use SetParameter(”paraName”, typeof(YourClass).FullName, NHibernateUtil.ClassMetaType)

  • Mapping

  • <any> : default meta-type is “string” (was “class”)
  • Licensed under: CC-BY-SA with attribution
    Not affiliated with StackOverflow
    scroll top