An important step which is often overlooked when beginning the process of mapping your database is to set the Build Action to Embedded Resource. (Buildvorgang – Eingebettete Resource). If you forget to do this you may receive a QuerySynataxException stating that the … is not mapped [from …]. It is also possible to store the […]
Read More →Tags: NHibernate
NHibernate could not execute query, ORA-00904 invalid identifier
This is a pretty easy one to solve. This happens because the column attribute in the mapping file does not exist on the database being accessed. <property name=”SpelledWrong” column=”SPELLDWRONG” type=”string” /> More than likely there is a spelling mistake or the column doesn’t exist on the table being mapped.
Read More →NHibernate Serialized startup
In all of my NHibernate implementations I serialize the startup. It saves a noticeable amount of time. We know that without it, NHibernate validates all the mapping files each time we start the program. If we only have 1 or 2 simple files it is not a problem, however, if you have a large implementation, […]
Read More →Nhibernate MappingException could not compile the mapping document
The following error is generally caused when there is a misspelling or case miss match between the class file and the mapping file. Review the contents of both and confirm spelling and case are the same so that the ‘Could not compile the mapping document: hbm.xml’ error can be avoided. The inner exception is something […]
Read More →NHibernate 3.2, What’s New?
The newest release is as BETA 1 when writing this blog an it contains some new and nice features. One of my favorite is that as a programmer we no longer need to configure a proxy. It was always a little confusing knowing which one to choose, I.e. looking in the Required_For_LazyLoading directory and deciding […]
Read More →Using LIKE with LINQ to NHibernate in C#
The equivalent to LIKE via the LINQ to NHibernate provider is Contains. An example of a LINQ to NHibernate that will return a result set matching a search like parameter is below. IQueryable<Classname> linqLIKE = (from m in session.Query<Classname>() where m.Code.Contains(“%dex%”) orderby m.CreateDate select m); IList<Classname> ListLIKE = linqLIKE.ToList(); The above […]
Read More →Upgrade from Oracle 10g to Oracle 11g with ODP.net and NHibernate ORA-12514
Firstly, let me say that there is nothing special about this upgrade. The instructions which I wrote here will still work with an 11g database. The issue I had was more with, what is the difference between a SID and a SERVICE_NAME which is used to identify the data instance to connection to. The SID […]
Read More →Attempted overcomplicated solution for a complicated system
I was working on a system which had implemented NHibernate, primarily for its ability to support multiple DBMS, such as Oracle and MS SQL Server. The problem came up when trying to insert, specifically in regards to the ID data type. On Oracle the ID data type was NHUMBER, while on MS SQL Server the […]
Read More →LINQ generated NHibernate and Entity Framework SQL (JOIN)
In continuation of a previous blog which compared 2 simple SELECT statements between NHibernate and Entity Framework, I do the same with the joining of 2 tables together. NHibernate Figure 1 shows the LINQ to NHibernate query which selects all the data from the PostForNHibernate table, joins with the BlogForNHibernate table using the foreign key […]
Read More →NHibernate mapping experience with an ambiguous reference
Sometime things don’t always go as planned. I was making some nice progress with the process of mapping a database and all of a sudden I get the following compile time error message. Ambiguous type reference. A type named “Attribute” occurs in at least two namespaces. “Attribute” ist ein mehrdeutiger Verweis und kann “System.Attribute” oder […]
Read More →