nhibernate-mapping

Nhibernate: <map> and <many-to-any>

What I do wrong? <map name="Aspects" table="AspectToEntity"> <key column="EntityID" /> <map-key column="AspectName" type="string" /> <many-to-any id-type="long" meta-type="string"> <column name="AspectName" /> <column name="AspectID" /> </many-to-any> </map> Exception: Repeated column in mapping for collection: Entit...

Mapping interface or abstract class component

Please consider the following simple use case: public class Foo { public virtual int Id { get; protected set; } public virtual IBar Bar { get; set; } } public interface IBar { string Text { get; set; } } public class Bar : IBar { ...

NHibernate: Change from lazy=true to fetch=join brings back the world

hi all, I have a User object/mapping in my application. Each user has a list of contact information (phone, email etc) the mapping for the user contains: <bag name="ContactInfo" table="contact_info" lazy="true" cascade="all"> <key column="contact_id"/> <one-to-many class="...ContactInfo, ..."/> </bag> this works fine but i g...

NHibernate map foreign key

I have two tables, Vehicle and Make. The two are joined using the MakeId as a foreign key on the Vehicle table. My mapping file looks similar to this <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Demo.Business.Objects.Vehicle, Demo.Business.Objects" table="V...

How to implement correctly IUserType?

I need to create a custom type for NHibernate by writing a new mapper class that implements IUserType. While it is relatively straightforward to override most of the methods and properties, I get some difficulties to understand how to deal correctly with the following members: object Assemble(object cached, object owner); object DeepCo...

Nhibernate Fluent domain Object with Id(x => x.id).GeneratedBy.Assigned not saveable

Hi there, I am using for some legacy db the corresponding domainclasses with mappings. Now the Ids of the entities are calculated by some stored Procedure in the DB which gives back the Id for the new row.(Its legacy, I cant change this) Now I create the new entity , set the Id and Call Save. But nothing happens. no exeption. Even NH Pr...

NHibernate: How to automatically delete many-to-many associations (cascade)

In my database I've got Users and UserGroups which have a many-to-many relation. The User has a set of UserGroup, the UserGroup domain object does not see the User. <class name="User" table="UserTable"> <set name="UserGroup" cascade="save-update" access="field.pascalcase-underscore" table="User2UserGroup"> <key column="User_...

NHibernate Inheritance Mapping

I know in NHibernate you can have inheritance mappings, and I know you can have table-per-class, table-per-subclass and table-per-concrete-class but they don't quite fit the scenario I have. Basically what I want is to be able to have a base class called product that looks like this: public class BaseProduct { public virtual int ...

[NHibernate] A correct way to load entities by Id list when Id is not mapped

I have the following code string idName = builder.IdentifierName; Disjunction disjunction = Restrictions.Disjunction(); IList ids = new ArrayList(entityInfos.Length); foreach (var entityInfo in entityInfos) { ids.Add(entityInfo .Id); } disjunction.Add(Restrictions.In(idName, ids)); criteria.Add(disjunction); criteria.List(); (I ha...

"extend" an xml schema

I'm trying to "extend" an xml schema (nhibernate here, for example), to add my own entities inside of it. I'm stuck to the point where validation chokes on the "exm:foo" (and exm:foobar) entity, as the "base" schema doesn't allow it. How can I manage to do that, without changing the base schema ? Sample : <?xml version="1.0" encoding="...

nhibernate mapping question

I have a set of tables, with a .hbm.xml for each. I tried to put in a named query but it would not compile. I moved the code to a CreateQuery and get. DB_Portfolio is not mapped [select sum(p.Shares * s.Price) from DB_Portfolio p, DB_Securities s where p.AccountNumber = :accountNumber and p.CUSIP = s.Cusip] The CreateQ...

Mapping custom enum classes with Fluent Nhibernate

Reading some posts from Jimmy Boggard and wondering - how exactly is it possible to map those beasts with fluent nhibernate? How mapping would look like for this?=> public class EmployeeType : Enumeration { public static readonly EmployeeType Manager = new EmployeeType(0, "Manager"); public static readonly EmployeeType...

FluentNHibernate - AutoMappings producing incorrect one-to-many column key

Hi I'm new to NHibernate and FNH and am trying to map these simple classes by using FluentNHibernate AutoMappings feature: public class TVShow : Entity { public virtual string Title { get; set;} public virtual ICollection<Season> Seasons { get; protected set; } public TVShow() { Seasons = new HashedSet<Season>...

What's the most productive way to do NHibernate mapping?

I know annotations to do the hibernate mapping in Java and am looking now for a similar way to do the same in C# and NHibernate. I found out that there exists several approaches do the mapping in xml files NHibernate.Mapping.Attributes (NHMA) Fluent are there any more?? I tried NHMA and found out it had some blocking points for me......

fluent NHibernate one-to-one relationship?

I have a problem with one-to-one relationships in the fluent nHibernate. I have the following relational table from the AdventureWorks2008 database. BusinessEntity (Table) BusinessEntityId Int (PK, Identity) Person (Table) BusinessEntityId int (PK, Reference with BusinessEntity table) FullName varchar(255) The relationship...

Nhibernate change from lazy=false to fetch=join many-to-many

i have: <bag name="Categories" table="CMS_Articles_Categories" lazy="true"> <key column="article_id"/> <many-to-many class="Framework.CMS.Domain.Category, Framework.CMS" column="category_id"/> </bag> This is under an Article mapping. An article can be in many categories and of course a category has many articles. When this is ...

Peculiar scenario for loading child objects using nHibernate

Hi guys, I've got a "weird" scenario in an app I'm writting, and trying to get to grips on ow I can implement using nHibernate. The scenario goes like this ... there is a Test. A Test is made up of a series of Testlets ( a Testlet is a set of pre-defined questions, with metadata ... ). The thing ... while I'm running the test, the ...

RIA Services does not support entities that are decorated by NHibernate mapping attributes?

...

Fluent NHibernate mapping: one table, many classes

How would I go about mapping three classes to one table with fluent NHibernate. A "Type" column should indicate which class should be mapped. Is it even possble? Kristoffer ...

How do I map class like Types<Type> in NHibernate ?

I have a need for specialize collection of custom types in my Domain Model. public class Foos : List<Foo> { } Is there a way to map this object in NHibernate and how could I use FluentNHibernate to do this as well ? ...