Questions tagged [nhibernate-mapping-by-code]

Mapping-by-code is NHibernate's own API by which mappings can be configured by code. Introduced in NHibernate version 3.2.

Mapping-by-code is NHibernate's own API by which mappings can be configured by code. It was introduced in NHibernate version 3.2. In a strict sense this applies to the namespace NHibernate.Mapping.ByCode. It may als pertain to NHibernate.Cfg.Loquacious, but not FluentNhibernate, which has its own tag.

158 questions
2
votes
2 answers

NHibernate Table Per Subclass results in nonsensical INSERT statement - What am I doing wrong?

I have the following entities: public abstract class User : IIdentity { private readonly UserType _userType; public virtual int EntitySK { get; set; } public virtual int TenantSK { get; set; } public abstract string Name { get; set;…
2
votes
1 answer

NHibernate mapping by code - composite unique index

How do I create a composite UNIQUE constaint on 3 properties of a class? It needs to allow NULL as a legitimate value.
2
votes
0 answers

nhibernate doing eager fetch by default

i am using nhibenate by code mappings. for some reason it is doing eager fetching by default, whereas it should be lazy. below is the mapping i have: public EntityMap() { Lazy(true); Id(x => x.Id, map => { …
user2165424
2
votes
2 answers

NHibernate: Setting datatypes and lengths explicitly for query parameters

I am using NHibernate mapping by code and sql server 2012. I am also using the Sql2008ClientDriver as the driver in the session factory. I have been trying to figure out how to map the exact sql type and length to the C# objects representing the…
Prabu
  • 4,097
  • 5
  • 45
  • 66
2
votes
1 answer

Joined sub-classes inheriting from unmapped, abstract intermediate classes

I have a class hierarchy that conceptually looks similar to this: That is, there's an abstract base class (Relation) and a couple of derived classes. In practice, Customer and Supplier share a lot of code, so I refactored the commonoalities into an…
Andre Loker
  • 8,368
  • 1
  • 23
  • 36
2
votes
2 answers

NHibernate - map interface or abstract component with mapping-by-code/Conformist

This question is related to Mapping interface or abstract class component I'm also trying to map a component declared as an interface, but I'm using the built-in mapping-by-code/Conformist approach. Let's say I have an entity Login (C#): public…
2
votes
1 answer

NHibernate 3.3: Mapping many to many relationship with composite foreign keys

I am trying to figure out how to map the following situation using NHibernate's "sexy" mapping by code system. Please help as I have been trying to figure this out for a while with no luck! I am using components to represent the composite keys.…
Prabu
  • 4,097
  • 5
  • 45
  • 66
2
votes
1 answer

NHibernate mapping by code: Mapping legacy non-int ID key to an int property in my entity getting "Could not determine type for" exception

I have a legacy database that uses zero-padded numbers stored as VARCHAR(8) for the primary key values in the tables. (For example, "00032982") I want to map these to Int32 properties in my entity objects instead of string. My first attempt was to…
2
votes
1 answer

NHibernate composite-element mapping-by-code

I'm trying to learn NHibernate mapping by code by translating the examples in 'NHibernate in Action' and I'm having a problem with one of the examples. I've inlcuded the the XML that I'm trying to translate and my effort at translating it. The…
2
votes
1 answer

How do I integrate a ComponentMapping with conformist mapping?

I'm starting a new project using conformist mappings. I have a common set of fields pulled out into a component mapping as such: public class AuditTrailMap : ComponentMapping { public AuditTrailMap() { Property(x =>…
JeffreyABecker
  • 2,724
  • 1
  • 25
  • 36
2
votes
0 answers

nHibernate map a filtered bag to a single property

I need to map an etity to a mater tabele of a DB. This Entity has OneToMany with another. I need to map a Collection othe the master entity to all rows of the Child table. But I also need to map a Property with a single row getted from the child…
2
votes
0 answers

Conditional mapping of entity id using mapping by code and nhibernate without fluent nhibernate

I'm trying to convert from fluent nhibernate to the build in mapping by code (Loquacious) in 3.2 now using 3.3 of nhibernate. The problem I have is conditional mapping of the Id column depending on type. I'm now using something similar to this which…
2
votes
1 answer

subclass of class with compositeid

is the following hbm.xml mapping possible in MappingByCode?
Firo
  • 30,626
  • 4
  • 55
  • 94
1
vote
1 answer

nHib 3.2 mapping by code join on composite key

My (legacy, can't be changed) schema has a one-to-one relationship between User and UserAddress, with a composite key: Users: - username (PK) - email (PK) - firsname - lastname UsersAddresses: - username (PK, FK) - email (PK, FK) - city -…
J. Ed
  • 6,692
  • 4
  • 39
  • 55
1
vote
1 answer

NHibernate Map By Code - Many To Many - Two way navigation

I'm pretty new to NHibernate. I have working many to many mappings. they look like this: public abstract class EntityMapping : ClassMapping where T : Entity { public EntityMapping() { Id(x => x.Id, map => map.Generator(new…