nhibernate-mapping

Inner or Right Outer Join in Nhibernate and Fluent Nhibernate on Many to Many collection

How can I force NHibernate to do a RIGHT outer join or an INNER join instead of a LEFT outer join on a many to many collection? The reason I would want to do this is because of filtering applied to the collection elements. With a left join, you get the same number of rows returned as an unfiltered query, but the elements that are filter...

Strange relationship mapping question for NHibernate

I have a unique situation working with a legacy application where I have a parent/child relationship that is based on two integer values. Unfortunately, these fields are not id and parentId or something similar. The columns are ItemId and SubItemId. When these two columns equal each other, the item is assumed to be a parent. When the...

Help me get List<Customers> like following in nhibernate?

I have class following. When i mapping file also following. I only get IList but i have not get List(of OrderTemp). Help me. Public Class CusTemp Private _CustomerID As String Private _CompanyName As String Private _ContactName As String Private _ContactTitle As String Private _Address As String Private _City As ...

How to map these classes the correct way with Fluent NHibernate?

Hello all, I have the 2 following classes: public class Player : BaseEntity<int, Player> { public string FirstName { get; set; } public string LastName { get; set; } public int Number { get; set; } public IList<Team> Teams { get; set; } public void AddTeam(Team team) { ...

Single class maps to two table join

Hi, looking at an existing NHibernate implementation that maps a single class to two database tables that are joined. The current functionality is read-only. The table join is actually hidden away via a readonly view and it's the view that's referred to in the NHibernate mapping. Works fine for readonly behaviour. Except I need to add I...

Can NHibernate be configured fluently to delete children when their references are set to null?

I've heard this can also be accomplished with triggers, but I'd rather not go that road if I can. Right now it seems like nulling references to child objects just leaves them orphaned in the database, which isn't ideal to say the least. Thanks! ...

Using Temporary Objects causes Transient Object Exception

I have an object where I maintain a relationship to another object: public class Foo { public Bar Bar { get; set; } } In the mapping I reference Bar to that I can maintain the relationship - I don't want the parent object to update properties in the child, just the existence of the relationship: References(x => x.Bar, "BarId") ...

How do I map a property with no setter and no backing property fluently with NHibernate?

Let's say I have the following entity: public class CalculationInfo { public virtual Int64 Id { get; set; } public virtual decimal Amount { get; set; } public virtual decimal SomeVariable { get; set; } public virtual decimal SomeOtherVariable { get; set; } public virtual decimal CalculatedAmount { ge...

Mapping large string with Fluent NHibernate

HI Guys, I'm working with an Oracle DB, and I'm trying to map this class: public class Book { public virtual int Id { get; private set; } public virtual string Author { get; set; } public virtual string Title { get; set; } public virtual string Text { get; set; } } With this mapping class: public class BookMap : Class...

Mapping 1 to 0..1 in Fluent NHibernate.

Lets say i have two entities; QuestionAnswer(Id, AnswerValue) Note(Id, QuestionAnswer_Id, NoteValue) How would I map this in Fluent Nhibernate? I know that there is a HasOne mapping but this is for a 1 to 1 unless im mistaken? I could also map it as a 1 to M but would require a List<Note> as a navigation property on my QuestionAnswer ...

NHibernate NVarchar <-> CustomClass Mapping

I have an entity which is constructed from a string and can be serialized to a string, e.g. public class EntityPart { public EntityPart(string str) { // some construction logic } public override string ToString() { // some serialization logic } } and a domain object that contains a property of this t...

NHibernate View Mapping Question

Consider an application consisting of Employees and Administrators. An employee consists of an EmployeeId, Name and EmailAddress. The employees are stored in a legacy system and are readonly so I have an immutable Employee class mapped to a view (vw_Employee) as follows: [vw_Employee] -> EmployeeID(key), Name, EmailAddress Now for t...

How to use UNION in nHibernate?

Hello, I knew nHibernate does not support UNION. But there are some tricks, we can implement the same like : Using raw-sql Using sub-union class I have an old application which is using <join table></join table> Now, I want to implement UNION here. Here are the file(s) in application: file: .hbm.xml <hibernate-mapping xmlns="u...

'NHibernate.Mapping.Property' is not an attribute class

This code fails to compile with the error 'NHibernate.Mapping.Property' is not an attribute class. Any ideas why? using System; using System.Linq; using DevExpress.Xpo; using System.Collections.Generic; using System.Text; using NHibernate.Mapping; namespace Test { public class User : IdentityItem { public string email; publ...

NHibernate Cacaded delete not working on one-to-many association

Hi, I am trying to delete an object and cascade the delete to the child objects in a one-to-many association. I think that I have done everything correctly for this to work. However, when I run my test, NHibernate attempts to insert a null value into the foreign key column of the child table rather than deleting the items. From my pare...

Storing a Set of Integer values in Sql Server 2005 with nHibernate?

What is the best way to store and map an Entity which contains a set of Integer as one of its attributes? I am using nHibernate over Sql Server 2005. Will creating a CLR Custom Type will help here? If yes how it can be mapped using nHibernate? I should be able to query on the Set. E.g. select myEntity from MyEntities where myEntity.In...

Doing table per subclass using a discriminator with NHibernate.Mapping.Attributes

I'm trying to do Table per subclass: using a discriminator using NHibernate.Mapping.Attributes. The hbm should look like this: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <subclass name="SalesReport" discriminator-value="SalesReport" extends="Report"> <join table="SalesReport"> <key foreign-key="FK_SalesReport_Doc...

NHibernate Component inheritance

Is it possible to do inheritance with NHibernates component? A quick google returned only a hand full of appropriate results (all blogs) and all were written some time ago so was wondering if it is available yet? if not how do you handle it instead? ...

Fluent NHibernate: IEnumerable component mapping from a single query?

Hi, Hoping you can help me with a mapping problem I have. At the moment I have a view which returns something such as: Name | Title | Price | Date | Format | FormatPriority | Example data may be: Bob | Credits | 340 | 01/01/2010 | BAR | 10 | Bob | Credits | 340 | 01/01/2010 | FOO | 20 | Bob | Credits | 340 | 01/01/2010 | WOO | 40 | ...

nhibernate <subclass><join> nest another sublass mapping (cause duplicate insertion of leaf class)

What's wrong with this mapping? On saving an instance of Class3, two rows in Table_2 will be inserted! first row has Column4 set to null and correct value of Column3, and second row has Column3 set to null and correct value of Column4! <class name="Class1" table="Table_1"> <id name="Column1"> <generator class="native" /> ...