{"id":65,"date":"2007-09-03T07:36:47","date_gmt":"2007-09-03T06:36:47","guid":{"rendered":"http:\/\/thekua.com\/atwork\/2007\/09\/03\/upgrading-from-nhibernate-102-to-120ga-experience-report\/"},"modified":"2012-03-01T20:51:25","modified_gmt":"2012-03-01T20:51:25","slug":"upgrading-from-nhibernate-102-to-120ga-experience-report","status":"publish","type":"post","link":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/","title":{"rendered":"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report"},"content":{"rendered":"<p>We recently upgraded to the latest version of NHibernate to make use of many of its new features. There are plenty of good reasons to upgrade including proper support of .Net 2.0, bug fixes, multi queries, new database dialects (including SQL Server 2005) and the ability to use generic types. We anticipated a few issues upgrading NHibernate, and though not the hardest upgrade ever, we did end up with a few more issues than expected. Here&#8217;s our experience upgrading to the latest version.  <\/p>\n<p><strong style=\"text-decoration:underline\">Things they warned you about<\/strong><\/p>\n<p>The NHibernate guys did a fantastic job writing their migration guide. They warned us that it wasn&#8217;t just simply a drop-in replacement and included a number of breaking API changes. Things that we found easy and had been documented included:<\/p>\n<ul>\n<li>Updating our XML files from <code>urn:nhibernate-mapping-2.0<\/code> to <code>urn:nhibernate-mapping-2.2<\/code><\/li>\n<li>Replacing <code>outer-join=\"true\"<\/code> to <code>fetch=\"join\"<\/code> and <code>outer-join=\"false\"<\/code> to <code>fetch=\"select\"<\/code><\/li>\n<li>Adding <code>default-lazy=\"false\"<\/code> to each mapping file to deal with the change in default lazy loading behaviour<\/li>\n<li>The HSQL <code>count<\/code> had been upgraded from an <code>int<\/code> type to a <code>long<\/code> type and our code had to cast it to the correct types<\/li>\n<li>Deprecation of the <code>CreateSQLQuery<\/code> with parameters changed to <code>ISQLQuery(String)<\/code> <\/li>\n<\/ul>\n<p><strong style=\"text-decoration:underline\">Things not on the label<\/strong><\/p>\n<ul>\n<li><strong>Strange behaviour around the <code>nosetter.camelcase<\/code> access strategy<\/strong> &#8211; We had a property exposing a primitive type (string) of a more complex type, given the same field name and we kept getting a null result. It looked like it was trying to set the field using the type of the get property, even though the set should have been using the more complex user type. We fixed this by changing our mappings to <code>field.camelcase<\/code> instead of using the <code>nosetter.camelcase<\/code>.<\/li>\n<li><strong>SQL statement logging has changed<\/strong> &#8211; Our application listens very carefully to the Log4Net output that NHibernate generates, capturing each SQL statement and its parameters. Previous versions of NHibernate used to log their parameter values separately from their SQL statements, instead they are now logged on the single line. Thankfully our change was contained to two very small classes.<\/li>\n<li><strong>Replacing <code>IClassPersister<\/code> with <code>IEntityPersister<\/code><\/strong> &#8211; We had to add a different constructor to our custom user types (also different from the current documentation), with a signature of <code>PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactory required, IMapping mapping<\/code>. Additionally we had to implement the new property <code>Factory<\/code> that came along with this interface. Now I had no idea where <code>ISessionFactoryImplementor<\/code> came from. Looking at the code, they had cast <code>ISessionFactory<\/code> in their constructor, and then returned that when the property <code>Factory<\/code> was called. It is a small inconsistency in their API that we ended up having to duplicate. This would be a problem if you ended up writing your own <code>ISessionFactory<\/code> but thankfully we haven&#8217;t done that ourselves. There were plenty more methods that we had to implement though none of them were actually very insteresting for the things that we had to do. <strong>Our solution:<\/strong> Cast ISessionFactory to ISessionFactoryImplementor and store it in the constructor just to be returned in the property.<\/li>\n<li><strong>IUserType Classes Disappearing<\/strong> &#8211; They had warned you that <code>IUserType<\/code> had moved into another namespace though I wasn&#8217;t quite clear what you had to do if you were using one of the old versions. In the end <code>new Int16SqlType()<\/code> is replaced by <code>SqlTypeFactory.Int16<\/code>, <code>new Int32SqlType()<\/code> by <code>SqlTypeFactory.Int32<\/code>, <code>new Int64SqlType()<\/code> by <code>SqlTypeFactory.Int64<\/code>, and <code>new GuidSqlType()<\/code> by <code>SqlTypeFactory.Guid<\/code>. I&#8217;m guessing it would be the same for any other IUserTypes you may be using.<\/li>\n<li><strong>IUserType New Methods<\/strong> &#8211; Four new methods appeared on the interface, <code>GetHashCode<\/code>, <code>Replace<\/code>, <code>Assemble<\/code>, <code>Disassemble<\/code>. Implementing GetHashCode we ended up delegating to our object, replace we delegated to using disassmemble then assemble, and implemented assemble and disassemble using DeepCopy, emulating what NHibernate Types do. It wasn&#8217;t really clear to me from documentation or upgrade guides what it should be<\/li>\n<li><strong>NHibernate.HibernateException : Could not instantiate cache implementation<\/strong> &#8211; It look like second level caching was now enabled by default and we hadn&#8217;t added configuration for it. We kept getting &#8220;Second-level cache is not enabled&#8221; messages. We disabled it and fixed this problem by explicitly turning it off. The property key is <code>hibernate.cache.use_second_level_cache<\/code> and turn it off by using the value  <code>false<\/code>.<\/li>\n<\/ul>\n<p>For the most part, considering how much of the core hibernate functionality had changed, we haven&#8217;t had too many issues although it&#8217;s still early days. We are noticing slightly different behaviour in the way that the flush semantics seem to be working (maybe auto flush mode is on by default now) though everything is still working quite pleasantly. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recently upgraded to the latest version of NHibernate to make use of many of its new features. There are plenty of good reasons to upgrade including proper support of .Net 2.0, bug fixes, multi queries, new database dialects (including SQL Server 2005) and the ability to use generic types. We anticipated a few issues [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4],"tags":[21,22],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-net","category-development","tag-nhibernate","tag-open-source","post-preview"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report - patkua@work<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report - patkua@work\" \/>\n<meta property=\"og:description\" content=\"We recently upgraded to the latest version of NHibernate to make use of many of its new features. There are plenty of good reasons to upgrade including proper support of .Net 2.0, bug fixes, multi queries, new database dialects (including SQL Server 2005) and the ability to use generic types. We anticipated a few issues [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/\" \/>\n<meta property=\"og:site_name\" content=\"patkua@work\" \/>\n<meta property=\"article:published_time\" content=\"2007-09-03T06:36:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-03-01T20:51:25+00:00\" \/>\n<meta name=\"author\" content=\"Patrick\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@patkua\" \/>\n<meta name=\"twitter:site\" content=\"@patkua\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Patrick\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/\"},\"author\":{\"name\":\"Patrick\",\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/#\\\/schema\\\/person\\\/c942203c9ed3ff9e21c6c49a996ea3ae\"},\"headline\":\"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report\",\"datePublished\":\"2007-09-03T06:36:47+00:00\",\"dateModified\":\"2012-03-01T20:51:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/\"},\"wordCount\":711,\"commentCount\":1,\"keywords\":[\"nhibernate\",\"open-source\"],\"articleSection\":[\".Net\",\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/\",\"url\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/\",\"name\":\"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report - patkua@work\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/#website\"},\"datePublished\":\"2007-09-03T06:36:47+00:00\",\"dateModified\":\"2012-03-01T20:51:25+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/#\\\/schema\\\/person\\\/c942203c9ed3ff9e21c6c49a996ea3ae\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/2007\\\/09\\\/upgrading-from-nhibernate-102-to-120ga-experience-report\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/#website\",\"url\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/\",\"name\":\"patkua@work\",\"description\":\"The intersection of technology and leadership\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/#\\\/schema\\\/person\\\/c942203c9ed3ff9e21c6c49a996ea3ae\",\"name\":\"Patrick\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2ef85a5f91c2aac13efb3ac90077b4db7f8883cafd6e60f2bcecba6b092d4011?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2ef85a5f91c2aac13efb3ac90077b4db7f8883cafd6e60f2bcecba6b092d4011?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2ef85a5f91c2aac13efb3ac90077b4db7f8883cafd6e60f2bcecba6b092d4011?s=96&d=mm&r=g\",\"caption\":\"Patrick\"},\"sameAs\":[\"http:\\\/\\\/thekua.com\\\/atwork\"],\"url\":\"https:\\\/\\\/thekua.com\\\/atwork\\\/author\\\/patrick\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report - patkua@work","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/","og_locale":"en_US","og_type":"article","og_title":"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report - patkua@work","og_description":"We recently upgraded to the latest version of NHibernate to make use of many of its new features. There are plenty of good reasons to upgrade including proper support of .Net 2.0, bug fixes, multi queries, new database dialects (including SQL Server 2005) and the ability to use generic types. We anticipated a few issues [&hellip;]","og_url":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/","og_site_name":"patkua@work","article_published_time":"2007-09-03T06:36:47+00:00","article_modified_time":"2012-03-01T20:51:25+00:00","author":"Patrick","twitter_card":"summary_large_image","twitter_creator":"@patkua","twitter_site":"@patkua","twitter_misc":{"Written by":"Patrick","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/#article","isPartOf":{"@id":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/"},"author":{"name":"Patrick","@id":"https:\/\/thekua.com\/atwork\/#\/schema\/person\/c942203c9ed3ff9e21c6c49a996ea3ae"},"headline":"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report","datePublished":"2007-09-03T06:36:47+00:00","dateModified":"2012-03-01T20:51:25+00:00","mainEntityOfPage":{"@id":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/"},"wordCount":711,"commentCount":1,"keywords":["nhibernate","open-source"],"articleSection":[".Net","Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/","url":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/","name":"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report - patkua@work","isPartOf":{"@id":"https:\/\/thekua.com\/atwork\/#website"},"datePublished":"2007-09-03T06:36:47+00:00","dateModified":"2012-03-01T20:51:25+00:00","author":{"@id":"https:\/\/thekua.com\/atwork\/#\/schema\/person\/c942203c9ed3ff9e21c6c49a996ea3ae"},"breadcrumb":{"@id":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/thekua.com\/atwork\/2007\/09\/upgrading-from-nhibernate-102-to-120ga-experience-report\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thekua.com\/atwork\/"},{"@type":"ListItem","position":2,"name":"Upgrading from NHibernate 1.0.2 to 1.2.0.GA Experience Report"}]},{"@type":"WebSite","@id":"https:\/\/thekua.com\/atwork\/#website","url":"https:\/\/thekua.com\/atwork\/","name":"patkua@work","description":"The intersection of technology and leadership","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thekua.com\/atwork\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/thekua.com\/atwork\/#\/schema\/person\/c942203c9ed3ff9e21c6c49a996ea3ae","name":"Patrick","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2ef85a5f91c2aac13efb3ac90077b4db7f8883cafd6e60f2bcecba6b092d4011?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2ef85a5f91c2aac13efb3ac90077b4db7f8883cafd6e60f2bcecba6b092d4011?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2ef85a5f91c2aac13efb3ac90077b4db7f8883cafd6e60f2bcecba6b092d4011?s=96&d=mm&r=g","caption":"Patrick"},"sameAs":["http:\/\/thekua.com\/atwork"],"url":"https:\/\/thekua.com\/atwork\/author\/patrick\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":1,"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":1496,"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/posts\/65\/revisions\/1496"}],"wp:attachment":[{"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thekua.com\/atwork\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}