nhibernate-mapping

Ensuring inserts after a call to a custom NHibernate IIdentifierGenerator

The setup Some of the "old old old" tables of our database use an exotic primary key generation scheme [1] and I'm trying to overlay this part of the database with NHibernate. This generation scheme is mostly hidden away in a stored procedure called, say, 'ShootMeInTheFace.GetNextSeededId'. I have written an IIdentifierGenerator that c...

Named query not known error trying to call a stored proc using Fluent NHibernate

I'm working on setting up NHibernate for a project and I have a few queries that, due to their complexity, we will be leaving as stored procedures. I'd like to be able to use NHibernate to call the sprocs, but have run into an error I can't figure out. Since I'm using Fluent NHibernate I'm using mixed mode mapping as recommended here. H...

Left Join on Many-to-One Mapping

I have a reference to call that may or may not be there. When I add the nullable option it still doing Inner Join when I want an Left Join (show the left even if the right is null). Is this possible in the NH map? References(x => x.DefaultCategory, "CATEGORY_ID") .Nullable(); ...

NHibernate: Mapping multiple classes from a single table row

I couldn't find an answer to this specific question. I am trying to keep my domain model object-oriented and re-use objects where possible. I am having an issue determining how to provide a mapping to multiple classes from a single row. Let me explain with an example: I have a single table, call it Customer. A customer has several a...

Conditional NHibernate Named Query Mapping by Dialect

How might I use a stored procedure from NHibernate but at the same time keep the solution database-agnostic and the codebase clean of switch statements with a case for each Dialect? I expect to create a Named Query per database implementation containing the content of the database-specific sql implementation of the procedure. My dile...

FluentNHibernate mapping of composite foreign keys

I have an existing database schema and wish to replace the custom data access code with Fluent.NHibernate. The database schema cannot be changed since it already exists in a shipping product. And it is preferable if the domain objects did not change or only changed minimally. I am having trouble mapping one unusual schema construct illu...

How does Fluent NHibernate support the Import Entity

I want to create a strongly type object from a fluent NHibernate query. If I were using HQL and NHibernate I belive I would need: the class for the output Namespace Model Public Class namecount Public Overridable Property lastname() as string ... Public Overridable Property lastnamecount() as integer ... Pu...

Fluent Nhibernate Table-Per-Entity Mapping with Composite Primary/Foriegn Keys

In .hbm.xml the mapping I am after would look as follows - any idea how I can reproduce this in Fluent NHibernate...? <class name="Dinosaur" table="Dinosaur" > <composite-id> <key-property name="Id" column="Id"/> <key-property name="Period" column="Period"/> </composite-id> <property name="DinosaurType" c...

fluent nHibernate mapping of subclassed structure

I have a workflow class that has a collection of phases, each phase has a collection of tasks. You can design a workflow that will be used by many engagements. When used in engagement I want to be able to add properties to each class (workflow, phase, and task). For example a task in the designer does not have people assigned, but a ta...

NHibernate Mapping + Iset

Hi all I have a mapping file <set name="Friends" table="Friends"> <key column="UserId"/> <many-to-many class="User" column="FriendId"/> </set> I would like to specify extra columns for the friend table this creates. For example Approve (the user must approve the friend request) Is there a easy way? And update <?xml v...

Saving child collections with NHibernate

Hi, I am in the process or learning NHibernate so bare with me. I have an Order class and a Transaction class. Order has a one to many association with transaction. The transaction table in my database has a not null constraint on the OrderId foreign key. Order class: public class Order { public virtual Guid Id { get; set; }...

Creating NONCLUSTERED INDEX on column by convention or fluent map

Hi, I want to use schemaExport to generate my Database. So, I would like some help as one of my table needs to have a non-clustered index on one column. Is there any way I can use the IIndexConvention to implement it? I could use a custom attribute to distinguee the property and then apply the convention for example. Many thanks. ...

NHibernate mapping error SQL Server 2008 Express

Hi All, I tried an example from NHibernate in Action book and when I try to run the app, it throws an exception saying "Could not compile the mapping document: HelloNHibernate.Employee.hbm.xml" Below is my code, Employee.hbm.xml <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-impor...

NHibernate WCF Bidirectional and Lazy loading

Hi everyone, I'm just looking for some direction when it comes to NHibernate and WCF. At the moment i have a many to one association between a person and address. The first problem. I have to eager load the list of addresses so it doesn't generate a lazy loaded proxy. Is there a way to disable lazy loading completely? I never want ...

Problem with NHibernate

I am trying to get a list of Products that share the Category. NHibernate returns no product which is wrong. Here is my Criteria API method : public IList<Product> GetProductForCategory(string name) { return _session.CreateCriteria(typeof(Product)) .CreateCriteria("Categories") .Ad...

NHibernate Mapping and Querying Where Tables are Related But No Foreign Key Constraint

I'm fairly new to NHibernate, and I need to ask a couple of questions relating to a very frequent scenario. The following simplified example illustrates the problem. I have two tables named Equipment and Users. Users is a set of system administrators. Equipment is a set of machinery. Tables: Users table has UserId int and LoginName n...

Fluent NHibernate + multiple databases

My project needs to handle three databases, that means three session factories. The thing is if i do something like this with fluent nhibernate: .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())) the factories would pick up all the mappings, even the ones that correspond to another database I've seen th...

How to map categories with parent category in NHibernate

I have the following class : public class Category { public Category() : this("") { } public Category(string name) { Name = name; SubCategories = new List<Category>(); Products = new HashSet<Product>(); } public virtual int ID { get; set; } public virtual st...

MVC + Nhibernate + Oracle Schema Configuration

Our customer wants us to use a connectionstring with username = "external" and add schemaName "original" infront of our queries like: "select columnA from original.TableA" I dont want to change mapping files which are shared by other projects, tried adding default schema as: <property name="default_schema">original</property> But t...

NHibernate mapping for subclasses and joined-subclasses

In a project that I am working on, I have the following entities: Analyst, Client and Contractor. Each inherit from a base class User. public abstract class User { public virtual int Id { get; set; } public virtual string Username { get; set; } public virtual string FullName { get; set; } } I then have the other classes in...