If you receive this error then you have probably mixed up some data types between your class (class.cs) file and your mapping (class.hbm.xlm) file. For example you have a property defined in your class file as a string and then in your mapping file as an int. To repair the PropertyAccessException Invalid Cast (check your […]
Read More →Tags: NHibernate
NHibernate error, incorrect syntax near the keyword
Common sense, maybe…, worthy of a blog, absolutely. I was creating an ordering system using NHibernate and the table which stored the orders was called ORDER. This resulted in an error, which I believe would come from any data retrieval source, I just happen to be using NHibernate with SQL Server and Oracle. The error […]
Read More →Updating Child records with NHibernate using HQL-IQuery and C#
I tend to overcomplicate things, I think that I do it subconsciously in an attempt to make sure I give due diligence in the search for the best solution. I had a parent child relationship mapped out using NHibernate. Something like the below where there is a one-to-many bag in the parent class and a […]
Read More →Invalid Index N For This SqlParameterCollection using NHibernate
While trying to insert parent child composite key linked into a database I received this error: Ungültiger Index N für SqlParameterCollection mit Count=8 Invalid Index N For This SqlParameterCollection with count=8 When I added the: insert=”false” attribute to the 8th property in my mapping file, the issue was resolved. Start with the ID at 0 […]
Read More →Inserting Parent Child records using NHibernate IDENTITY INSERT OFF
One of the errors I received when I was trying to get the parent child insert to work with NHibernate was: Ein expliziter Wert für die Identitätsspalte kann nicht in der ‘CHILD’-Tabelle eingefügt werden, wenn IDENTITY_INSERT auf OFF festgelegt ist Cannot insert explicit value for identity column in table ‘IdentityTable’ when IDENTITY_INSERT is set to […]
Read More →NHibernate – object with same identifier value was already associated
One of the awesome capabilities of NHibernate is its 1st and 2nd level caching functionality. Each time a query is submitted for execution NHibernate first looks in the cache for the entity before taking the query to the database and selecting the data. There is a lot of terminology you need to know before you […]
Read More →Using NuGet to install your ORM into Visual Studio
I have spent a lot of time Working with NHibernate 3.0 and now am also giving some attention to the Entity Framework. One of the road blocks for using NHibernate is the initial configuration requirements. There are a significant number of actions which must be taken to get NHibernate working, where as, the Entity Framework […]
Read More →LINQ generated NHibernate and Entity Framework SQL
One of my favorite aspects of ORMs is that I no longer have to write SQL. I like this because I was never really good at it once it exceeded the joining of 2 tables. The really complicated queries I left with the SQL people or a DBA. Nonetheless, I still wanted to look at […]
Read More →NHibernate MappingException could not compile mapping document
This is a fairly common error message which a programmer will receive during the NHibernate mapping process. The inner exception was: {“persistent class NAMESPACE.CLASSNAME, NAMESPACE not found”} {“Could not compile the mapping document: NAMESPACE.CLASSNAME.hbm.xml”} The root cause of this error was that the class (class.cs) existed in the NAMESPACE.Common namespace and in my mapping file […]
Read More →NHibernate connection driver must be specified in the configuration section
I was in the process of pointing my NHibernate to an Oracle 10g instance using ODP.Net and I received the below error message: The connection.driver_class must be specified in the NHibernate configuration section. I had been using a locally installed Microsoft SQL Server database up to that point. It turns out that I needed to […]
Read More →