
{"id":135,"date":"2009-02-19T20:26:34","date_gmt":"2009-02-20T01:26:34","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=135"},"modified":"2009-02-19T20:26:34","modified_gmt":"2009-02-20T01:26:34","slug":"trying-nhibernate","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=135","title":{"rendered":"Trying NHibernate"},"content":{"rendered":"<p>I was recently doing and small research project and got kinda tired of mechanically spitting out all those boring chants like<\/p>\n<p><code>using (var cmd = new SqlCommand(\"SELECT foo, bar FROM abc\", conn)<br \/>\n{<br \/>\n     ...<br \/>\n}<\/code><\/p>\n<p>I felt like my ride on the ORM train is long overdue. I&#8217;ve been planning to try NHibernate too long, and now I have finally found free time to do that.<br \/>\n<!--more--><br \/>\nThe beginning was pretty decent. <a href=\"http:\/\/www.hibernate.org\/\">http:\/\/www.hibernate.org<\/a>, downloads, <a href=\"http:\/\/sourceforge.net\/project\/showfiles.php?group_id=73818&#038;package_id=73969\">binaries, and source<\/a>, <a href=\"http:\/\/www.hibernate.org\/hib_docs\/nhibernate\/1.2\/reference\/en\/html\/\">documentation<\/a>. So far so good.<\/p>\n<p>Never mind that the documentation is for version 1.2, and current version is 2.0. It is open source, after all, what did you expect? Moving on to quick start.<\/p>\n<p>ASP.NET? No, thanks, I prefer console applications for tests. Maybe I am old fashioned. Anyhow, seems to work alright. Only my assembly (and namespace) is not called <code>QuickStart<\/code>, it is called <code>HibernateFirst<\/code>. Had to fix it in about 8 places. Not cool. The error messages were pretty decent though, and quickly pointed me to the problem.<\/p>\n<p>They neglected to say I need to include the mapping file as a resource. It&#8217;s so obvious, huh? The error message was not very helpful this time.<\/p>\n<p><i>You should now create the database and this table manually, and later read the <a href=\"http:\/\/www.hibernate.org\/hib_docs\/nhibernate\/1.2\/reference\/en\/html\/toolsetguide.html\">Toolset Guide<\/a> if you want to automate this step.<\/i> No no, I want to automate this step now. Skip ahead to the toolset guide.<\/p>\n<p>Paragraph 16.1.2, &#8220;running the tool&#8221;.<\/p>\n<p><code>java -cp hibernate_classpaths net.sf.hibernate.tool.hbm2ddl.SchemaExport options mapping_files<\/code><\/p>\n<p><b><font color=\"red\">What?!<\/font><\/b> What Java? What classpath? I don&#8217;t have a single jar in the binaries, what are they talking about? Searching the Internet for the f-fine tool. No trace of it. Going to the source. Well, there is a <code>NHibernate.Tool.hbm2ddl.SchemaExport<\/code> class, but it has no <code>Main<\/code> method. What gives?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was recently doing and small research project and got kinda tired of mechanically spitting out all those boring chants like using (var cmd = new SqlCommand(&#8220;SELECT foo, bar FROM <a href=\"https:\/\/ikriv.com\/blog\/?p=135\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[14,4],"tags":[],"class_list":["entry","author-ikriv","has-more-link","post-135","post","type-post","status-publish","format-standard","category-db","category-hack"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=135"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/135\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}