nhibernate-mapping

How to map a set of enum type in Hibernate?

In hibernate, is it possible to define a mapping for a class to a set of enums? I've been able to find examples of how to define mappings of Sets and I've been able to find separate examples for how to map Enums, but I cannot figure out how to define a of Enums for a class. Could anyone please provide me with an example? This is ...

How do I map a protected collection in Fluent NHibernate?

I have tried using the Reveal property in Fluent but I can't get it to compile with a collection. I want one of my collections in an entity to be protected and not accessible anywhere except in the entity itself. Is this possible? Thanks Edit: Here's the code I'm trying to use, HasMany<Trip>(x => Reveal.Property<Trip>("_trips")); I'...

NHibernate inner join master-detail on a column other than the id

Assume the following mapping entries: < class name="Customer" table="customer"> <id name="InternalId" column="uintCustomerId" type="long"> <generator class="identity" /> </id> <!-- The BinaryBlob below is a 16 byte array - Think Guid.NewGuid().ToByteArray --> <property name="CustomerUid" column="uidCustomerId" type="BinaryBlob" not-...

Class design and NHibernate mapping question

I have an Address class that I want to use for other objects address info. Below I paste 2 example classes Company and Person that use Address class public class Company { public virtual string Name { get; set; } public virtual string Phone { get; set; } public virtual string Fax { get; set; } public virtual Address Add...

NHibernate + default getdate() column

How do I configure NHibernate to create the db schema with a column like this: create_dt datetime not null default getdate() I have this in the mapping file: <property name="create_dt" update="false" insert="false" generated="insert" not-null="true" /> Is there anyway I can inject the sql server specific default getdate(). The docu...

model for resource allocation

I'm working on a time management project and looking for some practical object / persistence models. Fowler has some great ideas on resource allocation in his Analysis Patterns book, but many are overkill for what I need right now, and by design, highly conceptual (as opposed to implementable) The focal conceptual object I'm thinking of...

Help with nHibernate design/ mapping

Hi, I have a pretty simple data model. Article (ID, name, body, date) Category (ID, name, count) Article_Category (articleID, categoryID) Comment (ID, articleID, name, body, date) How would I go about laying out my nhibernate mapping? Also, when I create a new article, it will only have the article and the ID of the category to ass...

How to bind a series of columns into a collection with NHibernate

Please believe me when I say I understand this isn't the "right" way to do this. File this under large-complex-legacy-system questions. We have tables describing OCR'd data of documents. Each document type has its own table. Each table is generated based on the types of fields it expects. So have a schema which looks a bit like this...

NHibernate DuplicateMappingException when two classes have the same name but different namespaces

I have a class in my domain model root that looks like this: namespace Domain { public class Foo { ... } } I also have another class with the same name in a different namespace: namespace Domain.SubDomain { public class Foo { ... } } For my mappings, I have a Mapping directory with a subdirectory called SubDomain that contains ...

nhibernate Polymorphic association

I have a problem width Polymorphic association in nhibernate. DocumentLocation Mapping : <class name="Document.DocumentLocation" table="DocumentLocation"> <id name="DocumentLocationId" type="Int32" unsaved-value="null"> <column name="DocumentLocationId" length="4" sql-type="int" not-null="true" unique="true" index="PK_Documen...

How to use Join with NHibernate.Mapping.Attributes?

I am trying to join two tables to map to a single entity using NHibernate.Mapping.Attributes. It works when there is only one property in the joined table. However, when there are additional properties they get mapped to the primary table instead of the joined table. [Class(Table = "primarytable")] public class Entity { [Id(0, Name ...

Nhibernate and multilingual data mapping

We are trying to design a site that will support multilingual data and we use asp.net and nhibernate for O/R mapping. After some googling we decided that for us its best to create the entity classes containing all fields we need for supporting the default (english) language and for each multilingual class we would create a new class cont...

domain inheritance to relational db - looking for a working db model

Hello: The focus of this question is primarily to develop a relational db scheme given the object model here. This part of the system is concerned with time based allocations made by Resources (different flavors of Employees & Contractors) to Activities (either a Project or an Account). Data entry is weekly, and the domain model must v...

how can I make nhibernate cascade save a set of objects with circular references?

I am assuming nhibernate can handle circular reference issues as I have not seen this mentioned otherwise in the docs or on google (but perhaps I have the wrong terms). Suppose I have a class which has as a member a reference to an instance of itself: e.g. class A { A Other; } I then create 2 objects and have them cross reference o...

NHibernate: Mapping multiple classes to the same view

Hi all, I need to map two different classes to the same view and receive an error that a duplicate mapping exists. Is this possible in NHibernate? If not, can anyone give direction as to how I can solve this mapping problem. I work with views which are set in stone. One view brings back data needed to split into two classes. The view lo...

nhibernate: how to map aggregates

Good afternoon, I'm trying to learn nHibernate and it's not terribly clear. I need to get the result of an sql query: select patient.name, discipline.description, sum(patient.enddate - patient.startdate) as totaltime from treatment join patient on patient.id = treatment.patientId join discipline.id = treatment.disciplin...

How to map IDictionary that has a IList value?

Using NHibernate, how can I map the following scenario: public class User { public virtual IDictionary<Project, IList<Role>> ProjectAssignments { get; set; } } In the database I have separate tables for User, Project and Role and a fourth table for the relationship. Any help would be appreciated. ...

How to get Nhibernate to handle non existing database columns gracefully

I am working on a project that requires the use of multiple databases that for the most part are completely identical but some columns might be missing. How do you get NHibernate to handle this for instance i have a table with 4 columns an index and 2 data coloumns that will always be availible but a singe customer does not want the colu...

NHibernate mapping: one-to-many where

I need to restrict a one-to-many collection by a date column with a value specified on the parent element. The 'where' attribute on set or bag looks perfect for this. NHibernate documentation describes the 'where' attribute as being for arbitrary SQL, so am I correct in assuming that I cannot use values from the parent class here as I w...

How can I use a composite-id with a class as the id field in fluent nhibernate?

I've got a mapping file like this: <class name="Resource" table="resource" discriminator-value="null"> <composite-id name="Key" class="Models.Bases.ClientKey, Models"> <key-property name="Id" column="ID" type="int"/> <key-property name="SiteId" column="clientID" type="int"/> </composite-id> <property name="Name" ty...