nhibernate-mapping

NHibernate MappingException. No Persister.

I'm trying to get NHibernate to work. I've got this class: mm.k.Domain.Kampagne (namespace/assembly is mm.k.Domain) In another Visual Studio project (Assembly mm.k.Infrastructure) I got my Mapping files (in a Mappings directory), my hibernate.cfg.xml and some repositories. Heres my mapping file: <?xml version="1.0" encoding="utf-8"...

NHibernate filter collection

Using NHibernate I want to filter a collection in a class to contain ONLY a subset of possible objects. Below I am including a sample table data to help explain. I can find no way to do this using NHibernate. Table:DataObject DataObjectId(PK) / Name / CurrentVersion 11 "data.txt" 2 12 "info.txt" 3 Table...

Nhibernate: one-to-many, based on multiple keys?

Lets assume I have two tables Table tA ID ID2 SomeColumns Table tB ID ID2 SomeOtherColumns I am looking to create a Object let's call it ObjectA (based on tA), that will have a one-to-many relationship to ObjectB (based on tB). In my example however, I need to use the combination of ID and ID2 as the foreign key....

(Fluent) NHibernate - Inhertiance on object level but not on table level

I have the following idea: Business object implemented as interface or abstract class with certain properties as read only to all layers except the DAL layer. I also want my business objects in another assembly than the DAL (for testing purposes), so marking the properties is not an option for me. Examples could be one to one relations...

fluent nhibernate problem mapping char(1) type

The map. public SocialCodeMap() { Id(x => x.SocialCodeId); Map(x => x.Name); Map(x => x.Code); Map(x => x.DisplayOrder); } And the Class. public class SocialCode { public virtual Guid SocialCodeId { get; set; } public virtual string Name { get; set; } public virtual char Code { ...

nhibernate mapping Ilist with composite-element.

I have been trying to work with DDD style for my e-commerce application. Most of my business logic are implemented using fake repositories. Now, I would like to use NHibernate to hook my Domain Model to a real database. I have a class Order which contains a list of OrderLines object public IList<OrderLine> OrderLines{ ... } //line 1 ...

NHibernate: set id to interface mapping

I try to write a (fluent) mapping against an interface public interface IOrderDiscount : IDomainObject<long> where public interface IDomainObject<IdT> : IDomainObject { IdT Id { get; } } like so (and all other thinkable varieties of access strategies) Id(d => d.Id, "DiscountId") .GeneratedBy.HiLo("9") .WithUnsavedValue...

SQL index on NHibernate list key column?

I have two C# classes, say Container and Item, and a unidirectional association: class Container { [...] public IList<Item> Items {get;set;} } The NHibernate mapping looks like this: <class name="Container"> [...] <list name="Items" cascade="all-delete-orphan"> <key column="ContainerId"/> <index column="Position"/> ...

wont save to database with guid as id- fluent-nhiberate

hi. i got problems with saving when i use Guid as identifier. can anybody se what i am missing here? i create my own guid so i dont want it to be generated by database. NOTE: i have tried the guid.combo in mapping to without any success. public class Order { public virtual Guid Id { get; set; } public virtual ICollection<Orde...

mapping of composite nested key

Hi, I am working with legacy database with nhibernate (but assume the solution will be very similar as in hibernate) and we have nested composite keys, what I mean is following, our keys have this structure (this is pseudo c# syntax): class PartnerKey { Public Int PartnerNr } Class TaxArtKey { Public String TaxArt } Class PartnerTaxAr...

NHibernate Criteria for a non-linked table

We are adding an attribute(tags) to a system. The attribute table is just a relation table without any foreign keys. Is there a way to add to the criteria to generate a where clause for the attribute table on a parent table. <class name="Account" table="dbo.Account" lazy="true" > <id name="Id" column="`AccountId`"> <generato...

Mapping nested components in Fluent NHibernate

Hi all, I have a 'User' Entity that contains an 'Address' Value Object. I have this mapping ok using FNH's Component concept. However, the Address VO also contains a Country which is another value object. I had assumed that this should be just nested as another component, but this doesn't seem to work. Can anyone tell me how I shoul...

Id property not populated

I have an identity mapping like so: Id(x => x.GuidId).Column("GuidId") .GeneratedBy.GuidComb().UnsavedValue(Guid.Empty); When I retrieve an object from the database, the GuidId property of my object is Guid.Empty, not the actual Guid (the property in the class is of type System.Guid). However, all of the other properties in the o...

NHibernate - Mapping parent/child one-to-many association from same table

I'm pretty new to NHibernate and am having a problem getting this kind of mapping to work. I'm using NHibernate 2.1.0.GA and NHibernate.Mapping.Attributes 2.0. I have a single table (t_Posts) related to itself as a parent/child relationship: t_Posts ------------------------ (PK) PostID bigint DatePosted datetime Body nvarcha...

nHibernate & sqlite mappings

I'm having real problems with setting up nHibernate with sqlite. Here is the hibernate.cfg.xml file: <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <prope...

Hibernate complex Mappings

We use a pesonal design to store modified rows. For the data we need to keep, we use 2 tables; the first with fields that don't change, the second uses soft delete. +----------+ +---------------+ | TableBase| | Table | +==========+ +===============+ | Id | | TableId | | FieldA | | Id | +--------...

Fluent NHibernate Automap does not take into account IList<T> collections as indexed

I am using automap to map a domain model (simplified version): public class AppUser : Entity { [Required] public virtual string NickName { get; set; } [Required] [DataType(DataType.Password)] public virtual string PassKey { get; set; } [Required] [DataType(DataType.EmailAddress)] public virtual string E...

Nhibernate question about extension object without changing the original mapping

Say i have a cms with only one object called Article (for the sake of this example) with an ID and a title. This CMS implementation becomes part of a framework and is used as a library: e.g. CMSFactory.CMS.SaveArticle(a); The problem is that depending on the project requirements an article object may have more fields such as SomeDate. I...

Field in mapped entity required

Hi I'm not sure if my problem is solvable in a more or less comfortable way. There is a class Person which has mapped 'hasOne' a participant. The person has a birthday but this field is not required on the person itself. But if I would like to add a participant to the person then the birthday is required. How to get rid of this mo...

Encapsulating a database design into my domain design that is compatible with NHibernate

Okay, I hope this makes sense! I have an object Box which contains Items in it. The database design is such that only inserts are done on the Items table, and negative quantities are inserted to represent items being removed from the box. For example, if you put 10 items in the box, and remove 3 items, this would result in 2 rows in the...