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
0
votes
2 answers

Mapping many-to-one with collection table

I have a simple case with two entities Machine and Product, where a Machine can have zero or one Product. The reverse association (which would be a collection of some kind) is not needed in code. The problem is in the database model which is legacy…
Koen
  • 3,626
  • 1
  • 34
  • 55
0
votes
1 answer

NHibernate Mapping By Code Many-to-One with an Intermediate Table

Here is the scenario. I have two classes, say Husband and Wife :D And the relation between these two classes are defined through a third intermediate table named People. classes: class Husband { public virtual int HusbandId { get; set; } public…
kaptan
  • 3,060
  • 5
  • 34
  • 46
0
votes
1 answer

How can I get NHibernate to delete orphans in a one-to-one relationship?

We have an object in our model, call it class X. There are several other classes in our model that have an instance of class X as a property, call them A, B, C, etc. This is essentially a one-to-one mapping, since each X can only belong to one…
Mason
  • 703
  • 6
  • 20
0
votes
1 answer

NHibernate Conformist mapping many-to-many using set of simple types instead of set of entities

I'm using NHibernate Conformist mappings. I've already creating some complex mappings using ManyToMany, OneToMany, Element, and Component relation types for my various collection properties. But I ran into one today that stumped me. public class…
0
votes
1 answer

How do I map by code with NHibernate?

I need to define a unique constraint on multiple properties. In XML this would look like: What is the mapping-by-code equivalent in…
0
votes
1 answer

nhibernate - map one table to many parents

I have one class that is used to log changes in all other classes in my system: public class HistoryLogEntry { public virtual long Id { get; set; } public virtual string EntityQualifiedId { get; set; } // <-- this contains both the entity…
0
votes
1 answer

Store Hbm.xml in folder, Load them on demand

What is the best way to store hbm files separately from entity assembly, and load them on demand? I assume I need to load xml file into HbmMapping instance and serialize it into Hibernate.Cfg.Configuration instance?
0
votes
1 answer

nHibernate mapping by code - how to populate object tree with nested collections

I can't seem to find a good example of what I want to do, using nHibernate mapping by code: I have an object "Message" that has a list of "Organisms" and each "Organism" has a list of "Drugs". Please forgive my pseudo example below: …
0
votes
1 answer

NHibernate many-to-one "on the fly"

I'd like to know if the next problem can be solved in a different way in NHibernate. Let's say we've this domain: public class A { public virtual B LastAssociationWithB { get; set; } public virtual ICollection CollectionAssociationOfB…
Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
0
votes
2 answers

Nhibernate add GAC assembly to mapping-by-code

I have EmployeeEntity stored in MyCompany.Entities.Employee.dll and EmployeeMap: ClassMapping in MyCompany.Mapping.dll, both in GAC. I use mapping-by-code to create ISessionFactory implementation like this: var config = new…
dbardakov
  • 651
  • 1
  • 8
  • 22
0
votes
1 answer

Mapping by code - two-way relation

I have a Parent-Children relation and currently, only a reference from each child to the parent exists (there is a foreign key column on the child table). I would like to add a readonly IEnumerable property to the parent, but I am failing to do…
Tomas Grosup
  • 6,396
  • 3
  • 30
  • 44
0
votes
1 answer

NHibernate - Map key returned as proxy, eager load?

I'm mapping by code using NHibernate. Here is the class: [Serializable] public class Person : ObjectBase { public virtual IDictionary Attributes { get; set; } } and here is the mapping: public class PersonMapping :…
0
votes
1 answer

Error when using custom function on NHibernate mapping-by-code's SqlInsert

I have an NHibernate mapping-by-code that works if using standard INSERT on standard SqlInsert class ProductTranslationMapping : ClassMapping { public ProductTranslationMapping () { . . SqlInsert…
Hao
  • 8,047
  • 18
  • 63
  • 92
0
votes
1 answer

Nhibernate and inheriting mapping-by-code

I have two classes, one inheriting from the other. The first shows a summary view of data (4+ columns) and the child shows a detail view (40+ columns). Both classes are accessing the same table and share the same columns being accessed. Can my…
ps2goat
  • 8,067
  • 1
  • 35
  • 68
0
votes
1 answer

Reason for MappingException: No persister for: MyClassProxy

In a SaveOrUpdate call I'm getting the MappingException No persister for: MyClassProxy. What's strange is that I am able to insert new rows with the code, but if that row exists and the repository tries to update it, I'm getting this…
Philipp M
  • 1,877
  • 7
  • 27
  • 38
1 2 3
10
11