nhibernate-mapping

NHibernate - 12 Months / 1 Year and DataBinding

What is the best way to handle this I have an application where I constantly have to "pivot" 12 month records into one year record/object to be able to display a single year per row in a DataGrid. I have been doing this work up until this point in DataSets with some ugly T-SQL to get the pivot to happen. I'm upgrading this application t...

Fluent NHibernate HasManyToMany and NotFound

I have the following FNH mapping fragment: HasManyToMany((c) => c.Plaintiffs) .LazyLoad() .WithTableName("invoicePlantiff") .WithChildKeyColumn("PersonReferenceID") .WithParentKeyColumn("invoiceID") .FetchType.Join(); Which produces the following HBM: <bag name="Plaintiffs" access="iServe.Design.CslaNHibernate...

NHibernate set mapping is not DRY?

I'm not an advanced NHibernate user, so this may be somewhat important, and I just didn't discover it yet.. but what the heck. Consider the class: public class House { public int Id { get; set; } public ISet<Room> Rooms { get; set; } } When specifying NHibernate Set element it's not enough to write: <set name="Rooms" /...

Nhibernate one-to-one mapping a class with itself

We have a situation where we want to define a relationship where a class (named Module) may or may not be related to a Module object that is a predecessor to it. There can be zero or none predecessors. The class looks like this: public class Module { public int Id { get; set; } // other stuff here ...

Can I trust NHibernate Fluent Automappings?

I am currently testing using NHibernate Fluent Automappings to map my domain objects and create my database schema. Is this a good or bad idea? ...

NHibernate one-to-many mapping problem

I have to map two simple table with a foreign key relationship. One of the tables is Contact containing columns id (primary key of type int),name, address and guid (newly added and is not the primary key). The other one is phone__number containing columns id (primary key of type int), contact___id (foreign key of id in contact table) and...

How to map two tables with a foreign key relationship in NHibernate?

There are two tables, Contact and Phone__number. Phone_number contains a column contact_id which is a foreign key to id in Contact table. How do I map these two tables in Nhibernate so that I get List of PhoneNumbers in my contact class. ...

NHibernate Fluent Automapping Across DLLs

I have a Person class in 1 project/dll and a StandardUser class that derives from Person in another project/dll. I have a Password class that contains a StandardUser (Password and StandardUser are in the same dll). I can't seem to get the fluent automapping to work with this scenario. It tells me: NHibernate.MappingException: An as...

Execute custom sql for one property in NHibernate

As I understand it NHibernate has a build in support for timestamps. However, it appears you can only instruct NHibernate to never update the property or always update it. In the project I am currently working on there are several tables which have both "created_time" and "updated_time", both are to be generated by the database. I can...

NHibernate fetch="join" mapping attribute does not appear to work

Mapping a dictionary with NH. Declaration is as follows: <hibernate-mapping ... <map name="CostsByRole" table="JobAccountingSnapshotCosts" lazy="false" fetch="join" access="nosetter.camelcase-underscore"> <key column="SnapshotId" /> <index column="RoleCode" type="String" /> <element col...

Query Unmapped Columns in NHibernate

I have a class that is mapped to a table using NHibernate. The problem is that only some of the properties are mapped to columns in the table. This is fine because the only columns we use for display are mapped, however I was wondering if there is any way to query against other columns in the table that aren't mapped to properties in my ...

NHibernate mapping generic classes

How does one create a mapping file for a generic class in NHibernate. Say I have a class Foo How would it look in the mapping document? class name="mydll.Foo ???? , mydll" ... I know if it was a Foo it would be: class name="mydll.Foo`1[[mydll.Fee, mydll]], mydll" Would it be something like: class name="mydll.Foo`1[[mydll.Fee, mydll],[m...

NHibernate Single Table Inheritance

I'm having trouble setting up a role based structure using inheritance and NHibernate. Basically I would like to have an abstract class called ObjectInRole. This class (and corresponding database table) contains a RoleId, an ObjectId, and an ObjectType (this would be the discriminator column). The discriminator column would be the obj...

NHibernate many-to-one fetching same item many times

In my model I have Games. Each Game has an Event associated with it, which is mapped as a many-to-one association. When I query for Games, within event with given EventId (different than its DB-PrimaryKey-id) NHibernate issues the following query for each and every Game: NHibernate: SELECT event0_.Id as Id8_0_, event0_.EventId as Event...

How can I map a private property in my base class?

Using fluent nhibernate, is it possible to map a private property in a base class? I have this defined in my base class: private DateTime? lastModifiedDT { get; set; } but when I map it like so: Version(Reveal.Property<EntityType>("lastModifiedDT")).ColumnName("LastModifiedDT"); I get a FluentNHibernate.UnknownPropertyException ...

NHibernate Fluent vs. Attributes

I'm interested in moving some NHibernate configurations/mappings into the code to help with some maintenance issues. Can anyone provide any advice/pros/cons/comparisons of Fluent NHibernate vs. NHibernate.Mapping.Attributes? I have some experience with Java Hibernate annotations, which I liked, but I'm curious if the NHibernate attribu...

Null value objects in NHibernate

I have a person entity containing an Address as a value object: public Person() { WithTable("Person"); Id(x => x.Id); Component<Address>(x => x.Address, a => { a.Map(x => x.Address1); a.Map(x => x.Address2); a.Map(x => x.Address3); a.Map(x => x.Town); a.Map(x => x.Postcode); }); } It states...

Set Identity Seed to 0 Using NHibernate SchemaExport

I'm using the SchemaExport class in NHibernate to generate my database from my .hbm.xml files. Is there a way to set the Identity Seed on my tables to 0 rather than 1? For ref tables, I prefer to have all my initial status ids set to 0, and I don't want to have to reset this value every time I regenerate my DB while in dev. I'm using SQL...

nHibernate, No row with the given identifier exists

I have a mapping along the lines of this. <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Model.Entities" schema="etl" assembly="Model" default-lazy="false"> <class name="Model.Entities.DataField, Model" table="mdm_field"> <id name="FieldId" column="field_id" type="int"> <generator class="native" /> </id...

Nhibernate mapping tool for MySQL

Is there any mapping tool for nhibernate-mysql? I want a mapping tool that Takes in a MySQL database General the relevant hbm.xml file Create the data access layer class that maps to each table. Is there any such tools available? ...