Dear all , Thank You for coming to my blogspot

Jun 18, 2008

Koreksi sample NHibernate pada bagian Addassembly agar dapat berjalan

Pada sample NHibernate yang dipublish di, menurut hemat saya, harus ada sedikit perbaikan agar dapar berjalan dengan lancar.
Adapun beberapa perbaikan tersebut adalah:
  1. Pada line code di file user.hbm.xml

    <class name="NHibernate.Examples.QuickStart.User, NHibernate.Example.QuickStart" table="users">

    Dalam hal ini anda harus tau maksud dari 2 input argument string yang diberikan pada tag name, argument 1 menunjukkan namespace + classname dan argument yang kedua menunjukkan assembly name, dalam hal ini assembly name dapat anda lihat pada nama asli file ini, silahkan buka explorer dan lihat difolder dimana file.dll ini dicompile.
    Selanjutnya terdapat pula tag table yang menunjukkan apa nama table reference di databasenya..
  2. Setelah perbaikan pada bagian ini kemudian compile, tapi ingat jangan lupa set file user.hbm.xml menjadi Embedded Resource, caranya mudah masuk ke tab Solution Explorer, kemudian klik file User.hbm.xml (jangan didoubleClick) kemudian langsung arahkan mouse ke Tab Properties kemudian rubah di bagian Build Action
  3. Masuk ke WebSite Project Anda : pada File Default.aspx.cs buat sedikit perubahan. dimana pada line code

    Configuration cfg = new Configuration();

    rubah menjadi :

    Configuration cfg = new Configuration();
    cfg.AddResource("NHibernate.Example.QuickStart.User.hbm.xml", System.Reflection.Assembly.Load("NHibernate.Example.QuickStart"));
  4. pertanyaannya kenapa function of AddAssembly dirubah ke AddResource, agar ketika buildSessionFactory langsung mengarahkan ke Embedded Resourcenya dalam hal ini "NHibernate.Example.QuickStart.User.hbm.xml" (lihat pada fisik filename-nya di folder anda) dan ditambah dengan Assembly Namenya, artinya file yang udah dicompile jadi Apa??? yaitu "NHibernate.Example.QuickStart" (sesuaikan dengan filename yang sudah tercompile difolder anda). Bila setiap line code anda tidak ada salah ketik dan lain-lain. maka sample ini dapat dijalankan dengan baik dan benar....

    selamat mencoba.....................

Created By Rahmad Hidayat @ June 2008

No comments :

About my own Company

Harsa Cipta Intiguna deliver a specific business domain in the IT World by providing IT Software Division so known as HarsaSoft, we would like to help and educate our client to gain the benefits from our highly skill, wide and deep knowledge, and fully experience experts in the related fields by getting the right sharped, effective and efficient software solution. We also create IT Hardware Division so called HarsaWare based on our market demand which could help you in gaining good quality gadgets, laptops and servers with competitive price and after sales warranty. We've made these possible to our existing client and we'll make these possible for you too by adapting and customizing to patch, enchance and adding rich features from the open source software, so you could use these features to help your business getting better and better a long the way as we would ourself getting better every day by making you satisfy with our products and services. We could provide end to end solution for you, so no need to worry that your IT System as the supporting business will become hard to manage and hard to improve for supporting the growing fast business. "No need reinventing the wheel but make it more useful" are the words that we have in mind and we also make sure that you leave your worries behind since we always give our client after-sales guaranty in order achieving our goal which is "Your satisfaction is ours". If you are interested to get the information about our products, please send an email to me, at

Note : please use your company email to request the brochure