Top 100+ Nhibernate Interview Questions And Answers
Question 1. Define Cascade In Nhibernate Mapping File?
Answer :
Cascade: allow operations to cascade to baby none shop-update all-delete orphan”
all: while an object is keep/replace/delete, check the institutions and keep/update/delete all objects located.
None: do not do any cascades, allow person handles them by using themselves.
Save-update: while the item is stored/updated, test the institutions and keep/update any item that require it.
Delete: when the item is deleted, delete all the objects within the association.
All-delete-orphan: when an object is keep/update/delete, test the associations and save/replace/delete all objects observed. Similarly to this, when an object is removed from the affiliation and no longer associated with every other item, delete the orphan item also.
Question 2. Explain About Nhibernate Mapping Files?
Answer :
Mapping documents form core of any database. These files include subject to area mapping, normally this mapping takes place among instructions and attributes.
Sample mapping report:
<?Xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="NhiberateSample"
namespace="NhibernateSample.Sample">
<class name="FirstSample">
<id name="Id">
<generator class="native" />
</id>
<property name="Name" />
<property name="Category" />
</class>
</hibernate-mapping>
No want to specify column name if database column call is equal as assets .
<property name="Name" column="database-column-name" />
Also, proper-click on on "FirstSample.Hbm.Xml", choose "Properties" and alternate the "Build Action" to "Embedded Resource".
The mapping record will now be a part of the Asssembly.
SQL Server 2008 Interview Questions
Question 3. How Do You Switch Between Relational Databases Without Code Changes?
Answer :
By using hibernate SQL dialects, we are able to transfer databases. Hibernate will generate suitable hql queries based on the dialect defined.
Question four. What Is Difference Between Session.Get() And Session.Load()?
Answer :
Both Session.Get() and Session.Load() method create a chronic item by loading the required object from the database. But if there was no longer an item in database, then ‘Load’ approach throws an exception wherein as Get method returns null.
SQL Server 2008 Tutorial
Question five. How To Configure Nhibernate?
Answer :
Configuration documents and mapping files(.Hbm.Xml) are used by Configuration elegance to create the SessionFactory, which in flip creates the Session example . Session example are number one interface for persistence service.
Config document is used to specify connection info and mapping files used to map persistant items to a relational database. It is fine practice to keep each item in an character mapping document.
SessionFactory is nhibernate concept of a single datastore and is threadsafe so that many threads can get admission to it simultaneously, SessionFactory is usually built best as soon as at startup
ASP.NET Interview Questions
Question 6. What Is Nhibernate.Burrow?
Answer :
Burrow is a light weight middleware evolved to guide .Net packages the usage of NHibernate (maybe also referred as NH in this newsletter) as ORM framework. Using Asp.Net with NHibernate may be a undertaking due to the fact that NHibernate is a stateful environment even as Asp.Net is a stateless framework. Burrow can help resolve this battle by using imparting superior and smart consultation/transaction management and other facilitates.
Question 7. What's The Major Benefits Offered By Nhibernate.Burrow?
Answer :
Burrow Conversation with which you may effortlessly write enterprise transaction
GenericDAO with which ISession may be seldom touched most of the time
Stateful field attributes with which marked fields of Asp.Net UserControl and Page could be stateful over a couple of http requests. It allows UserControls or Pages recollect entity without inflicting lazy load exception.
Multiple databases help multiple databases turns into clean, you don't need a SessionFactoryPath, you genuinely supply Burrow an entity type, and Burrow will discover the right ISession for you. If you are the usage of GenericDAO, the more than one DB support may be very transparent - your code does not want to realize there are multiple databases.
ASP.NET Tutorial LINQ Interview Questions
Question 8. How Do I Learn More About Nhibernate.Burrow?
Answer :
Introduction - a short introduction.
Get Started - tells a way to setup the Burrow framework.
Burrow Conversation Explained - offers more element in long verbal exchange.
StatefulField Attributes - explains how Burrow.WebUtil attributes can simplify states upkeep for ASP.NET controls and pages
Question 9. Why Did I Get This "cannot Find Entity With Id X" Error With My [entityfield] After I Deleted It?
Answer :
That's because with the aid of default EntityField is the use of Session.Load() to load the entity for you. If you delete the entity, you need to reset that area to null, in case you want to keep this problem, you could use [EntityFieldDeletionSafe] rather, it's basically the equal besides that it's the use of Session.Get().
IBM Tivoli Interview Questions
Question 10. How Do I Store Data In Httpsession?
Answer :
You may already know that you can not store entity in HttpSession in an OpenSessionPerView mode which is what NHibernate.Burrow is using most of the cases. Instead, you could store entity id in session and cargo the entity with Id on every occasion you operate it. Thanks to NHibernate's cache, this might not carry any performance trouble on your device.
LINQ Tutorial
Question eleven. How Do I Do Unit Test Under Nhibernate.Burrow?
Answer :
follows.
[SetUp]
public void Initialize()
new BurrowFramework().InitWorkSpace();
[TearDown]
public void Close()
new BurrowFramework().CloseWorkSpace();
Or you could use NHibernate.Burrow.TestUtil.TestBase as your NUnit unit take a look at base elegance and override TearDowan() and SetUp() technique to add your own TearDown and SetUp common sense.
Windows Presentation Foundation(WPF) Interview Questions
Question 12. Is Nhibernate.Burrow Compatible With Ajax?
Answer :
NHibernate.Burrow is well suited with Ajax.Asp.Net - the ajax framework furnished via Microsoft.
SQL Server 2008 Interview Questions
Question 13. Why I Couldn't Finish A Long Conversation In An Updatepanel In An Ajax.Asp.Internet Project?
Answer :
If you preserve getting a javascript alert window giving the mistake message "Sys.WebForms.PageReqeustManagerParserErrorExcpetion: The message obtained from the server could not be parsed. Common reasons for this mistake are whilst the reaction is modified with the aid of calls to Response.Write(), reaction filters, HttpModules, or server hint is enabled." you want to feature the subsequent placing into you system.Internet phase in your internet.Config
<pages enableViewStateMac="false" viewStateEncryptionMode="Never" enableEventValidation="false">
Windows Presentation Foundation(WPF) Tutorial
Question 14. What Version Of Nhibernate Is Nhibernate.Burrow Using?
Answer :
Burrow 1.Zero alpha 1 is using NHibernate 2.0 Alpha 1.
Question 15. What Version Of .Net Framework Does Nhibernate.Burrow Support?
Answer :
NHibernate.Burrow presently best works in .Net Framework 2.0
Windows Communication Foundation (WCF) Interview Questions
Question 16. Does Nhibernate.Burrow Create Session And Transaction For Every Http Request?
Answer :
Some current OpenSessionPerView helping HttpModule answers create pointless consultation and transaction for every http request which include requests for digital property which includes picture and css document. NHibernate.Burrow simplest creates consultation and transaction for http request handler that needs.
Windows Communication Foundation (WCF) Tutorial
Question 17. How Do I Change Nhibernate Configuration Within Burrow On The Fly?
Answer :
you can use the following code:
IFrameworkEnvironment fe = new BurrowFramework().BurrowEnvironment;
NHibernate.Cfg.Configuration cfg = fe.GetNHConfig("PersistenceUnit1");
...
//do anything exchange you need to cfg
fe.RebuildSessionFactories();
Ibm Tivoli Netcool Omnibus Interview Questions
Question 18. What Version Of Hibernate Is Nhibernate Ported From?
Answer :
NHibernate 1.0 is a port of Hibernate 2.1. Some difficult to understand functions of Hibernate 2.1 are missing from NHibernate and some simple functions from Hibernate three are gift.
ASP.NET Interview Questions
Question 19. I Get An Error Saying No Persisters Found For Myclass?
Answer :
This frequently takes place while there may be a typo in a mapping file, or whilst you forget to set the build motion for the document to Embedded Resource in Visual Studio .NET.
Dynamic Link Library (DLL) Tutorial
Question 20. I've Changed The Mapping File, But Still Get The Same Error I Was Getting Before - Why Isn't Nhibernate Reading The New Mapping File?
Answer :
If you assemble the mapping documents into an assembly as an /Embedded Resource (my personal recommendation) and you use Visual Studio .NET 2003 for development, then you definitely need to rebuild the task, now not just build it if all that became changed is a hbm.Xml record. VS.NET will now not rebuild a project if best an embedded resource has changed - so the assembly nevertheless carries the old hbm.Xml document.
Dynamic Link Library (DLL) Interview Questions
Question 21. Why Doesn't My Proxy Work?
Answer :
To be capable of create a proxy for a category, the magnificence must have its houses, strategies and events declared as digital. This is not required if the class is proxied via an interface it implements (unique using proxy="SomeInterface"). There isn't any code in NHibernate 1.Zero to validate your proxy training, however with the intention to be introduced in NHibernate 1.1.
NHibernate makes use of the library Castle.DynamicProxy this is part of the Castle Project. DynamicProxy generates IL - not modifying your IL - at runtime for a subclass of your elegance, or the IL to put into effect an interface.
Question 22. Does Nhibernate Modify My Il? If Not, How Do You Know What Has Changed?
Answer :
No, it does no longer modify your IL in anyway. Your IL stays precisely as it become while you compiled it.
When an object is loaded by way of NHibernate the ISession keeps a picture of the state of your item. When you Flush() the ISession NHibernate compares that image to the current country of the object. The appropriate adjustments are written to the database.
Adaptive software development Tutorial
Question 23. How Do I Translate The Nhibernate Collections To .Internet Collections?
Answer :
The names of the gathering mappings is one apparent place in which the variations among Java and .NET are shown. Java's collection library has many more alternatives than System.Collection does.
The <list> maps directly to an IList.
The <map> maps immediately to an IDictionary.
The <bag> maps to an IList. A <bag> does now not absolutely comply with the IList interface due to the fact the Add() approach isn't always guaranteed to go back the suitable index. An item can be added to a <bag> without initializing the IList. Make certain to either cover the IList from the consumers of your API or make it nicely documented.
The <set> maps to an Iesi.Collections.ISet. That interface is part of the Iesi.Collections meeting disbursed with NHibernate.
If an order-through characteristic is introduced to the collection mapping detail then the concrete collection type will exchange to one which helps keeping the order an element became brought. For a <bag> it still uses an ArrayList. For the <map> and <set> which have an order-via characteristic the concrete collection class changes to a Specialized.ListDictionary and Iesi.Collections.ListSet, respectively. This need to be a non-difficulty for the reason that customers of your API are using the interfaces IList and Iesi.Collections.ISet.
If a sort characteristic is added to the collection mapping detail then the concrete series type will exchange to one which supports ordering. For the <map> and <set> that have a kind attribute the concrete series elegance modifications to a SortedList or Iesi.Collections.SortedSet, respectively, that uses the IComparer provided inside the sort characteristic. This ought to be a non-problem to the consumers of your API considering the fact that they may be the usage of the interfaces IList and Iesi.Collections.ISet.
Using an order-through or sort attribute does have implications on performance for maps and sets as the size of the collections grows. Please study the MSDN documentation approximately the ListDictionary and SortedList overall performance implications. There are also some top articles on The Code Project about collections.
Advanced C# Interview Questions
Question 24. What Is A Persistent Collection?
Answer :
This term is utilized in NHibernate to refer to a group of its inner elegance (NHibernate.Collections.Set, List, Bag, and many others.) which wraps a user's series. All collections belonging to entities lower back through NHibernate are chronic (= wrapped). Entities surpassed to Save also have their collections wrapped and replaced by means of the wrappers as a part of the saving manner. Persistent collections have a picture of their unique country and may therefore be updated extra effectively.
Collections containing question outcomes are not persistent, they may be plain .NET collections (=ArrayList=s).
LINQ Interview Questions
Question 25. Nhibernate Is Deleting My Entire Collection And Recreating It Instead Of Updating The Table?
Answer :
This generally occurs when NHibernate can not parent out which objects modified within the series. Common causes are:
replacing a persistent series totally with a new series example
passing NHibernate a manually constructed object and calling Update on it.
Serializing/deserializing a chronic collection reputedly additionally causes this trouble.
Updating a <bag> with inverse="fake" - in this case, NHibernate can't assemble SQL to replace an individual series item.
Thus, to keep away from the trouble:
pass the identical collection instance that you obtain from NHibernate again to it (no longer necessarily inside the identical session),
strive using a few other series as opposed to <bag> (<idbag> or <set>), or
strive the usage of inverse="actual" attribute for <bag>.
