nhibernate-mapping

Using NHibernate with an EAV data model

I'm trying to leverage NH to map to a data model that is a loose interpretation of the EAV/CR data model. I have most of it working but am struggling with mapping the Entity.Attributes collection. Here are the tables in question: -------------------- | Entities | -------------------- | EntityId PK |-| | EntityType |...

Series of abstract classes and NHibernate

Hello, and first off thanks for your time to look at this. For a research project I'm working on, I have a somewhat complex design (which I've been given) to persist to a database via NHibernate. Here's an example of the class hierarchy: TransitStrategy, TransportationCompany and TransportationLocation are all abstract classes. The...

NHibernate mapping an Dictionary to sql database

I've got the a class created in code an added it to my class diagram. The class diagram is used by a text template generatorto generate code from this class diagram. I'm trying to map a dictionary to an sql database with NHibernate, the generated mapping looks ok to me, but the class property as shown below is giving me problems. This i...

nHibernate Mapping file

in the nHibernate Mapping file i have an issue the issue is i have a table a mapped to table b in the table b i am mapping to table c. When i try to select some values from table a its generating the sql statement with all the rows in table a,b,c thats fine but the issue is i want to select table c column as a property how do i do this?...

NHibernate one-to-one with composite-id problem

My error message: NHibernate.MappingException : broken column mapping for: ItemDetails.id of: NHibReg.Domain.RegDetail, type Int32 expects 1 columns, but 2 were mapped I get this when I try to get a RegDetail row: How can I solve this? Here is the RegDetail MAP: <class name="RegDetail" table="******"> <composite-id> <key-prope...

Prevent lazy loading in nHibernate

Hi, I'm storing some blobs in my database, so I have a Document table and a DocumentContent table. Document contains a filename, description etc and has a DocumentContent property. I have a Silverlight client, so I don't want to load up and send the DocumentContent to the client unless I explicity ask for it, but I'm having trouble do...

Prevent Nhibernate schemaexport from generating foreign key constraints on has many relationship

I have a mapping like this: HasMany(x => x.Orders).KeyColumn("CustomerID"); Which is causing a constraint like this to be generated by schemaexport: alter table [CustomerOrder] add constraint FK45B3FB85AF01218D foreign key (CustomerID) references [Customer] I have tried adding .NotFound.Ignore() like on a References(...

NHibernate From One-To-Many to One-To-One

I am creating the security system for the software im creating and I would like to know how i can do the following in NHibernate(if at all possible) User Account Class: public class UserAccount { public virtual int UserID { get; set; } public virtual String Username { get; set; } public virtual Privilege InvoicePrivilege { ...

Query regarding the Nhibernate many to many mapping

Hi, I have a requirement where i have 3 dimension tables (employee, project, technology) and a common fact table which has the key id's of all these three tables. My question goes like this... How do i create a mapping table (fact table) having these three columns - emp_id, proj_i and tech_i. I know we can achieve this for two tables u...

Load collections eagerly in NHibernate using Criteria API

I have an entity A which HasMany entities B and entities C. All entities A, B and C have some references x,y and z which should be loaded eagerly. I want to read from the database all entities A, and load the collections of B and C eagerly using criteria API. So far, I am able to fetch the references in 'A' eagerly. But when the collec...

nhibernate : mapping to column other than primary key

I have the following map. My intention is for the order.BasketId to map to orderItem.BasketId. Tho when i look at the sql i see that it's mapping order.Id to orderItem.BasketId. How do i define in my order map which order property to map against basketId. It seems to default to the primary key. <class name="Order" table="Orders"> ...

nhibernate : One to One mapping

I have the following map. I wish to map BasketItem to the class "Product". So basically when i iterate thru the basket i can get the product name <class name="BasketItem" table="User_Current_Basket"> <id name="Id" type="Int32" column="Id" unsaved-value="0"> <generator class="identity"/> </id> <property name="ProductId" column="Item_ID" ...

nhibernate : how to intialise child list objects

I have the following method in my repository. This works fine, my orderItems are initialised as intended however orderItems contains another collection called OrderItemAddress. These are not initialised. How would i do this? public Model.Order Get(int id) { using (ISession session = NHibernateHelper.OpenSession()) { Mode...

NHibernate single column id that refererences another object

I have a class whose primary key is a single column, which is a reference to another object's single column primary key. The only way I can see to map this in NHibernate is to pretend it's a composite key (even though it's a single column key) and use the key-reference mapping. Is there a more appropriate way? Snippet below: class Comp...

nHibernate Mapping file

<property name="NetworkRunId" column="Network_Run_Id" /> <property name="StudyKey" column="Study_Key" insert="false" update="false" /> <property name="AnnualizationFactor" column="Annualization_Factor" /> <property name="CreateDate" column="Create_Date" /> <property name="ModifyDate" column="Modify_Date" /> <many-to-o...

Fluent Nhibernate - Mapping child in parent when Child has reference to parent and not using a list

I have a child object in the database that looks like this: CREATE TABLE Child ( ChildId uniqueidentifier not null, ParentId uniqueidentifier not null ) An then I have a parent like so. CREATE TABLE Parent ( ParentId uniqueidentifier not null ) Now, the problem is that in my Parent class, I have public virtual Child Child { get;...

How to add a WHERE clause on the second table of a 1-to-1 join in Fluent NHibernate?

I'm using a legacy database that was 'future proofed' to keep track of historical changes. It turns out this feature is never used so I want to map the tables into a single entity. My tables are: CodesHistory (CodesHistoryID (pk), CodeID (fk), Text) Codes (CodeID (pk), CodeName) To add an additional level of complexity, these table...

Triggers in NHibernate

Hi everybody, I'd like to know if is there something like a Trigger (of databases) in NHibernate that I can use per entity ? I'd like to make a history of each record, and with triggers I can compare the old value and new value of each property and generate a register of history. I've heard about Audit in NHibernate, but it's for al...

Cascading items in a collection of a component

I have a component which contains a collection. I can't seem to get NHibernate to persist items in the collection if I have the collection marked as Inverse. They will persist if I don't have Inverse on the collection, but I get an insert and then an update statement. My mapping is : m => m.Component(x => x.Configuration, c => { c...

IntegrationTests for NHibernate.MappingException: No persister for:

If I forgot to add mappings to a persister object, NHibernate will throw an exception when I'll run the application. I want to write an integration tests, that test that all mappings are provided to NHibernate. what is the way you recommend to follow? ...