nhibernate

nHibernate Criteria Query OR or IN?

Hi there people. I need to recreate a query using nHibernate Criteria. This query had a where clause that was pretty ugly. ((t.Disposition_CD)='ac' Or (t.Disposition_CD)='cc' Or (t.Disposition_CD)='Co' Or (t.Disposition_CD)='SF' Or (t.Disposition_CD)='SC' Or (t.Disposition_CD)='OR' Or (t.Disposition_CD)='SV' Or ...

How to get NHibernate mapping info from an Entity/Object

Given an entity instance, how do I get mapping information like table name, identifier column name, number of columns, etc? ...

Implementing NHibernate Unit Test to Generate Schema with VB.NET/MBUnit

Hi, I'm trying to implement unit tests for my NHibernate data access layer. The first test, which I drew from an example I found on the web (http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/01/your-first-nhibernate-based-application.aspx), is just trying to recreate the database using my domain classes/mappings. I've been...

How to save a child with assigned id in nhibernate

I have two classes: public class Parent { public virtual long? ID { get; set; } // native public virtual IList<Child> Children { get; set; } public virtual string Name { get; set; } } public class Child { public virtual long ID { get; set; } // assigned public virtual string Name { get; set; } } Instantiating and ...

NHibernate Session with IIS 7

I have a ASP.NET MVC application using NHibernate and the application runs fine when running it through VS2008 virtual web server, but when I tried running the site through my local IIS server I keep getting this NHibernate error: No session bound to the current context. I don't know what happened. Am I missing something? I just have my ...

get entites with relation count greater than x with nhibernate

Say i have a entity like this public class Something { public int Id{get;set;} public string Name{get;set;} public IList<SomeOther> Assosiation{get;set} } how can i query with nhibernate to get all the Something entities with more than 10 Assosiations using Criteria API? Cheers Colin ...

Hibernate key mapping problem

Hey there, I'm using NHibernate. I have two tables: Owner which has <id name="SpecificNumber" column="SpecificNumber" type="int"> <generator class="assigned"/> </id> <set name="SubTable" table="SubTable"> <key column="Owner_id"/> <one-to-many class="SubTable"/> </set> and a table SubTable which has <many-to-one name="Ow...

How to set a property of a property in NHibernate

How can I have the property of a property set using NHibernate? Here is an example (just an example!) public class Person { private FullName _subClassProperty = new FullName(); public FullName Name { get { return _subClassProperty; } set { return _subClassProperty; } } } public class FullName { public virt...

NHibernate Validator using other languages

How do I get NHibernate Validator to use other language than English for it's messages? There are several languages included, but I always get my messages in English. I have tried setting culture but nothing helps. Any help? regards, Jan ...

Issues when trying to remove the connection between two objects in a many-to-many relationship

Hi I have two entities: Group and ContactInfo. These are connected with a many-to-many relationship (mapped using Fluent NHibernate). I'm not able to remove a "ContactInfo" from a Group. The join-table is not updated. (It is when inserting new elements) My code (excerpt): public class GroupMap : ClassMap<Group> { public GroupMap(...

NHibernate - could not find (oracle) dialect in configuration

Hi, I've got following hibernate.cfg.xml <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory> <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property> <property name="connection.connection_string"> User ID=user;Password=password;Data Source=database </property> <prop...

How to map a many-to-many linking table to use another schema?

I have a few classes that I map to non-default schema using NHibernate.Mapping.Attributes like this: [Class(Lazy = true, Schema = "NonDefaultSchemaName")] public class Class1 I also have some many-to-many mappings: [Set(Inverse = false, Table = "Class1ToClass2", Lazy = true, Cascade = "none")] [Key(1, Column = "Class1ID")] [ManyToMan...

NHibernate: Getting single column from an entity

How can you get a single column back from a query instead of a whole object? I could do something like this to get the whole object, but all I want is the names: IList<Tribble> tribbles = session.CreateCriteria(typeof(Tribble)).List<Tribble>(); IList<string> names = new List<string>(); foreach (Tribble t in tribbles) { names.Add(t....

NHibernate ICriteria and Expected Types

Is there any way to get at the types of objects I would expect NHibernate to place in an ICriteria object as the result of running a query? In this code sample, I can get at the types of my objects if they aren't null, but what if they are? Also, depending on the data returned, one "row" (object[]) may have null fields in places where ot...

NHibernate query interception

Is there any way to get the query text - i.e. plain SQL - of an NHibernate query from a DetachedCriteria object (or any NHibernate object, I just want to be pointed in the right direction) BEFORE it is sent to my server? If so, can I prevent it from executing? ...

How can I determine if an object is reachable within an object graph in C#?

I have a pretty complex object graph G with an object o1 in G. G is to be written into a database using NHibernate. However, if there already is a persistent entry of o1 (let's call it o1_p ) in the database, I substitute o1 for o1_p. Hence there should be no redundant entries in the database. Now I let NHibernate do its job and afterwar...

How can I make NHibernate aware of a first-class "Null Object", without database persistence?

I would like to make use of the Null Object pattern in my domain, but I don't want to have records in my database that relate to it - I would prefer it if NHibernate were able to map a SQL null value to my Null object, and vice versa. Is this possible (using Fluent NHibernate for mappings) P.S. This seems like it is a fairly common iss...

NHibernate mysql connection not closed?

I am using NHibernate with mySQL 5 and I am a bit unsure whether NHibernate really closes the connection to mySQL. This is the code I am using in order to save a Player entity to the database: using (ISession session = SessionFactory.OpenSession()) { using (ITransaction transaction = session.BeginTransacti...

Solved - Querying an entity with a condition on an associated entity's property

I'm in a early phase of learning NHibernate, and currently I'm trying to select every person within a company or function. The code is listed below. I have some problems with conditions on the Person's associated properties. The person has one-to-many relation to Department, and I want to check the DepartmentName property of the related ...

How would I design a repository to handle multiple data access strategies?

What would a skeleton design look like for a repository able to support multiple database layers using ASP.NET MVC and C#? I want to see what a design would look like if I support both LINQ to SQL and NHibernate. How would I create my database object, and call a method on it in my BLL layer? ...