nhibernate-mapping

Mapping a collection of enums with NHibernate

Mapping a collection of enums with NHibernate Specifically, using Attributes for the mappings. Currently I have this working mapping the collection as type Int32 and NH seems to take care of it, but it's not exactly ideal. The error I receive is "Unable to determine type" when trying to map the collection as of the type of the enum I ...

NHibernate: How can I combine fields from two classes?

Here is a simplified version of my database model. I have two tables: "Image", and "HostingProvider" which look like this: [Image] id filename hostingprovider_id [HostingProvider] id base_url Image HostingproviderId is a many-to-one foreign key relationship to the HostingProvider table. (Each image has one hosting provider). ...

Is there any way to fake an ID column in NHibernate?

Say I'm mapping a simple object to a table that contains duplicate records and I want to allow duplicates in my code. I don't need to update/insert/delete on this table, only display the records. Is there a way that I can put a fake (generated) ID column in my mapping file to trick NHibernate into thinking the rows are unique? Creatin...

NHibernate: One base class, several mappings

I'm relatively new to NHibernate, but have been using it for the last few programs and I'm in love. I've come to a situation where I need to aggregate data from 4-5 databases into a single database. Specifically it is serial number data. Each database will have its own mapping file, but ultimately the entities all share the same basic...

NHibernate many-to-one and unique constraint violation

Hi all, I have a problem trying to model a many-to-one relationship in NHibernate, where the object on the 'one' side has a unique constraint on a column. The problem is as follows: I have two tables, 'Person' and 'Country'. Each Person has one and only one Country associated with it. A Country can have many Persons (really! :)) and a ...

Fluent NHibernate - how to map a subclass one-to-one?

Suppose I have three classes. It is valid to instantiate A, but there are also special cases B and D which subclass A, adding additional information. How would I do the mapping files for this in (fluent) NHibernate? public class A { public int ID { get; set;} public string CommonProperty1 { get; set; } public string Common...

Joining NHibernate Classes that share a common column but no foreign key

I have a couple of tables that I want to map to classes. The tables look like this: Asset --------- AssetId AssetName Product --------- ProductId ProductName AssetId Disposal --------- DisposalId AssetId DisposalDate Basically what I want to do is join the Product Table to the Disposal table on AssetId so that my Product has a colle...

Mapping a class with multiple collection properties containing the same object type

Our system generates emails with user-chosen lists of To / CC / BCC contacts. I wanted to store them as follows in our SQL Server database, here's the simplified database table structure: CREATE TABLE [Contact] ( [ContactID] [int] IDENTITY (1, 1) NOT NULL, [Name] [varchar] (100) NOT NULL, [EmailAddress] [varchar] (100) NOT ...

NHibernate - Is there any good tools to assist you with the configuration file?

Is there any GUI-based tools to assist you with writing and maintaining the configuration file? Any code tools to codegen the config file? What are the best ways to make this a little bit easier? Are most people just using Castle ActiveRecord now? ...

Fluent NHibernate: How to create one-to-many bidirectional mapping?

Hi, Basic question: How to I create a bidirectional one-to-many map in Fluent NHibernate? Details: I have a parent object with many children. In my case, it is meaningless for the child to not have a parent, so in the database, I would like the foreign key to the parent to have NOT NULL constraint. I am auto-generating my database f...

NHibernate Inheritance mapping when sub class in Separate Assemblly

Hi, Assume that core project have a base entity and every plugin maybe extend the base entity Solution structure : Application.Core.BaseClass Application.Module.SubClass (it's plug in, maybe not available) Is any way to implement this mapping with nhibernate subclass? Thanks and sorry for my bad english ...

NHibernate: Best way to deal with intermediary table using Fluent NHibernate?

How would you map the following in Fluent NHibernate? See "18.3. Customer/Order/Product" http://www.hibernate.org/hib_docs/nhibernate/html/example-mappings.html ...

NHibernate Many-to-many

Hi Guys. I have a legacy database and I am trying to create a Nhibernate DAL. I have a problem with a mapping on Many-To-Many table. The Database tables is like this. studio_Subscribers studio_Groups (contains a IList of Subscribers) studio_Subscribers_Groups - Many-To-Many table with primary keys The problem is when I create a Subscr...

Nhibernate ValueType Collection as delimited string in DB

Hi I have a legacy db that I am mapping with Nhibernate. And in several locations a list och strigs or domain objects are mapped as a delimited string in the database. Either 'string|string|string' in the value type cases and like 'domainID|domainID|domainID' in the references type cases. I know I can create a dummy property on the cla...

Can this mapping be done with (Fluent) NHibernate?

I have an Events table whose goal is to store actions done by web site users. An action basically alters or create a new row in a table X. This will allow me to store an history of all actions done by a user. As such, Events contains: a primary key column a text to describe the event (ex: "posted a comment") a discrimator column if nee...

NHibernate mapping with a class hierarchy whose base class is abstract and the discriminator is not a string

Here are the domain model classes: public abstract class BaseClass { ... } public class ChildClass : BaseClass { ... } Note that the parent class is abstract and this is what gives me some difficulties when comes the time to map with fluent nhibernate. My discriminator is a byte (tinyint in the DB). Because it is not a string and I c...

Normalizing EnumStringType in NHibernate

I am currently using an enumeration in an NHibernate mapped as follows.. public enum UploadMethod { Java, Silverlight, Gears, Flash } class UploadMethodType : EnumStringType { public UploadMethodType() : base(typeof(UploadMethod), 255) { } } public class Person { /* Bunch of non interesting properties... */ public Uplo...

Storing a comma separated list in a field using nHibernate

I'm building a blog using C# and nHibernate for my database persistence. I want to make the entries taggable so I have an IList for the tags property. But how do I map this to a comma separated list in a single column in my database? I want to avoid using a separate table for the tags and just keep them in one column as a separated lis...

Using Additional Data on Intermediate Table with NHibernate

I'm working on a project that is used to input information about a product into a document. One section has a form that can be filled out as many times as needed for a particular product. The information on this form is then available to be shared on multiple related documents. A typical many-to-many situation. The difference is, on ...

Could we have custom name of the primary key column in Fluent NHibernate?

I'm so surprise while I'm working in Fluent NHibernate. I got my legacy database that has primary key column name is different from my property in domain model. I'm sure that I can use this mapping file: <class name="Person"> <id name="Id" column="CommentId"> <generator class="native"/> </id> <property name="Description" typ...