nhibernate-mapping

NHibernate CreateCriteria query problem

I hope someone can help with this please. I am trying to query an OLAP Fact table with NHibernate, but am struggling to get it to work. Its seems a simple requirement but I just cant see what the problem could be. I have a central Fact table with several Dimension tables, one of the Dimensions has a secondary Dimension. So ERD is. Fa...

hibernate generator tag

Hi, What the exact purpose of ' native ' in hibernate mapping file of the generator tag ( I know by using genarator tag, it will genaerate the primarykey values ...) ....... .......... ...

Trying to map several bags with the same table - failed to lazily initialize a collection of role exception

I have a problem with mapping in nhibernate. I am using nhibernate 2.2 version. Seems like the problem is in mapping but I am not sure this is the cause. Anyway, I have two tables which I would like to map. I created a hbm file for first table and a data transfer object too. All columns were mapped and everything works fine here. But,...

Mapping a collection of entities in fluent nHibernate

I'm developing a question/answer based application I have a Post table in the db along the lines of: ID Title Body DateCreated AuthorID AuthorName (in case user not registered) AutherEmail (as above) PostType (enum - 1 if question, 2 if reply) Show (bit field) Then, there is "PostBase" - which is an abstract class (this has pro...

NHibernate mapping domain "extension properties"?

Hi, I would like to "extend" my domain classes without having to add data to the domain classes themselves. Concider I have the following class: public class Person { public virtual int Id { get; private set; } public virtual string Name { get; set; } } And I have the following table in the database: tblPersons---------------...

Fluent NHibernate: Custom condition (WHERE clause) on get, update and delete

I have a table that contains information from many customers ID | employeename | customerId ------------------------------ 1 | employee1 | 188 2 | employee2 | 188 3 | employee3 | 177 Now I would like to get only those employees, whose customerId is 188. How do I map this with Fluent NHibernate so, that on update and del...

NHibernate.MappingException: No persister No mapped documents found in assembly

Hello Everyone!! I have been doing nhibernate since many days. But Today I stuck at a frustrating issue i.e. mapping exception. <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="IPC.Base.Domains" assembly="IPC"> <class name="MenuItem" table="dbo.COR_MenuItem" default-access="...

Mapping collection of enum in NHibernate.

Hi all! I have a class with collection of enums: Class1.cs public enum Language { Serbian = 1, Croatian, Ukrainian, } public class Class1 { private IList<Language> m_languages = new List<Language>(); public virtual IList<Language> Languages { get { return m_languages; } set { m_languages = val...

Mapping Parent and Child Tables with Fluent NHibernate

Hi have the following tables defined in my database: Transactions: - TransactionID (PK, Identity) - TypeID (FK) - Amount TransactionTypes: - TypeID (PK, Identity) - Type ProductTransactions: - TransactionID (PK) - Discount There are 2 types of transactions (Events and Products). Products have an additional Discount field so an addi...

NHibernate: Recursive queries

Hi, I've got a basic tree structure that is stored in a single table. Let's say this is my model: public class TreeNode { public virtual Guid Id { get; private set; } public virtual string Name { get; private set; } public virtual IEnumerable<TreeNode> Contents { get; private set; } } and the table: TREE_NODES PK_NODE Guid ...

NHibernate: Using a discriminator column as a many-to-one relationship

I've got a two tables that i'm trying to map. Table1 has a many-to-one relationship with Table2 via the FK, fk_table2_id. In table1's mapping I also have a discriminator and a subclass defined, like so: <class name="MyAssembly.MyClass1, MyAssembly" table="table1" discriminator-value="null"> <discriminator column="fk_table2_id" type="i...

NHibernate: Discriminators without inheritance

I have the following model: public class SomeObject1 { public virtual Guid Id {get; set; } public string Property1 {get; set; } } public class SomeObject2 { public virtual Guid Id {get; set; } public string Property2 {get; set;} } and the table SOME_OBJECTS PK_SOME_OBJECTS Guid WHICH_OBJECT Integer PROPERTY1 varchar2 ...

2 foreign keys in same entity mapping to same primary key problem

Hello hope someone can help me on this. I have a situation where I have: User entity which stores all my users including admins. Comments entity which stores all comment against users. my problem is I'm also storing within the comment entity the user id of the admin who made the comment. So now I have the Comment entity having 2 userId...

FluentNhibernate one Hasmany one side mapping problem

Hi, I'm having a problem mapping the following classes public class Cat { public virtual int id { get; set; } public virtual string name { get; set; } } public class House { public virtual int id { get; set; } public virtual string name { get; set; } public virtual IList Cats{ get; set; } } And my DB tables look li...

Composite Key/Id Mapping with NHibernate

Hi, i have the following tables in my database: Announcements: - AnnouncementID (PK) - Title AnouncementsRead (composite PK on AnnouncementID and UserID): - AnnouncementID (PK) - UserID (PK) - DateRead Users: - UserID (PK) - UserName Note: Usually i'd map the AnnouncementsRead using a Many to Many relationship but this table also ha...

NHibernate - define fetching strategy dynamically

Let me explain the problem - hopefully I have defined it well in the title but I want to be sure. I have a linq query that pulls back a bunch of objects (say Foos). Each Foo holds a reference to a User. Each User holds a reference to a Person: public class Foo { //properties omitted... public User CreatedBy {get;} } public class Us...

Fluent NHibernate join not using primary key

I am trying to get a single property from a joined table where a non-PK in my main table is joined to the PK of the foreign table. Below is an oversimplified example of what I am trying to accomplish (I do not want to reference the foreign entity): Tables: CREATE TABLE Status ( Id int, Body text, CategoryId int ) CREATE TABLE C...

Using load-collection for an element with a composite key

Hi, I have two mappings, one with 2 named queries. Everything maps fine to the objects when I execute 2 separate repository calls - one for each object. The mappings for this are below: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Company.Application.Models" assembly="Company.Application.Models"> <class name="Pro...

NHibernate with schemaupadate and many-to-many

Is anybody knows how doesnt schemaupdate work with many-to-many e.g.: i have category and product entities with many-to-many on each one: how can i know when schemaupdate creates table: categoriesToProducts and when productsToCategories ps. i dont want to specify tableName in my mapping ...

NHibernate: Object with id was not of the specified subclass: (loading object was of wrong class )

Hi, I am getting the error below: Object with id: 34dd93d3-374e-df11-9667-001aa03fa2c4 was not of the specified subclass: MyNamespace.ClassA (loading object was of wrong class [MyNamespace.ClassB1]) Call stack is: at NHibernate.Loader.Loader.InstanceAlreadyLoaded(IDataReader rs, Int32 i, IEntityPersister persister, EntityKey key, Obje...