nhibernate-mapping

How can i view the mapping configurations passed to the NHibernate by the castle activerecord?

Is it possible to view the mapping configurations / mapping xml files passed from activerecord to nhibernate? ...

How to map to get value from primary table in Nhibernate?

I face a problem when I try to get value from primary table in my mapping file. My tables: CREATE TABLE Customer ( [CustomerId] INT PRIMARY KEY, [FullName] NVARCHAR(50) NOT NULL ) CREATE TABLE CustomerOrder ( [CustomerOrderId] INT PRIMARY KEY, [CustomerId] INT, [TransactionDate] DATETIME ) My classes: public cla...

NHibernate child to polymorphic parent mapping

Hi, Using NHibernate 1.2.0. I have a parent-child relationship with a polymorphic parent class. The child has a many-to-one "Parent" property referencing the base parent class. In HQL, starting from the child class, I need to access a property of one of the derived parent types. Something like: select parentA.SomeProperty from Chil...

NHibernate mapping - one-to-one (or one-to-zero)

NHibernatians! I have a table [dbo].[Wibble] and another table [dbo].[WibbleExtended]. [Wibble] is the main table and [WibbleExtended] is an optional table where some other fields are stored. There are far fewer entries in the [WibbleExtended] table than the main [Wibble] table. I think this was done back in the day to cure some spac...

NHibernate: how to enable lazy loading on one-to-one mapping

One-to-one relations within nhibernate can be lazyloaded either "false" or "proxy". I was wondering if anyone knows a way to do a lazy one-to-one mapping. I worked out a hack to achieve the same result by using a lazy set mapped to a private field, and having the public property return the first result of that set. It works, but isn't t...

How to map NHibernate from table A to table A itself with many-to-many?

Please help! I couldn't figure it out how to map the following situation: I have only 1 table. [Table] User { id, name } My class look like this public class User { public int Id { get; set; } public string Name { get; set; } public ISet<User> Friends { get; set; } } Each user has relationship with other users. e.g.'User...

NHibernate2 query is wired when fetch the collection from the proxy. Is this correct behavior?

This is my class: public class User { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IList<UserFriend> Friends { get; protected set; } } public class UserFriend { public virtual int Id { get; set; } public virtual User User { get; set; } public virtual User F...

Is it true that NHibernate ISession.save(newTransientEntity) will only return generated Id, but NOT updating the Id property of the entity?

Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA { ... [Id][Generator(class="guid")] public Guid Id {...} [Property] public string Property1 {...} ... } Let say if I add a transient entity to the persistence context with code like this: ... Guid id; using(IS...

NHibernate with string primary key and relationships

I've have just been stumped with this problem for an hour and I annoyingly found the problem eventually. THE CIRCUMSTANCES I have a table which users a string as a primary key, this table has various many to one and many to many relationships all off this primary key. When searching for multiple items from the table all relationships ...

How do you filter one to many relationships with fluent-NHibernate?

I have a set of entities where they could possibly be set as deleted using an "IsDeleted" flag in the database. This is fine for the normal set of entities, however when I have a parent with many child entities that may have this flag I would like NHibernate to be able to automatically handle selecting the child entities that have "IsD...

Nhibernate foreign key to foreign key collection mapping ?

I have a Staff and e SecuredPage entity and the properties are below Staff id Name LastName Level // SecuredPage.RoleId SecuredPage id PageId RoleId // Staff.Level I want to have a collection of SecuredPage in Staff entity, so it s a one-to-many but i couldnt figure it out how to handle with it in mapping. Staff.hbm.xml <bag name=...

How to map a deeper hierarchy in nhibernate

I have this object graph, I want to map: abstract Account (username, password, ...) abstract Customer (shoppingcart, orders, roles) IndividualCustomer (user data) CorporateCustomer (different user data, company data) Administrator (adminroles) How can this be mapped against one table? (I know how to do this with an entity hierarc...

Applying the Hibernate filter attribute to a Bag with a many-to-many relationship

Consider the following Hibernate mapping file: <hibernate-mapping ...> <class name="ContentPackage" table="contentPackages"> <id name="Id" column="id" type="int"><generator class="native" /></id> ... <bag name="Clips" table="contentAudVidLinks"> <key column="fk_contentPackageId"></key> <many-to-many class="Clip" ...

Cascade.SaveOrUpdate (SQLite) fluent-nhibernate

Hi, I have a many-to-many relationship between two classes: Tournament and Players I set Cascade.SaveUpdate in the mappings, but when saving a Tournament instance, the Players will not be saved to the Players table. Nhibernate only writes parent and child key columns in the linking table. The DB is SQLite. These are the mappings pub...

Fluent NHibernate question

Let's say you have two tables, "Users" and "UserRoles". Here's how the two tables are structured (table - columns): Users - UserID (int) UserRoles - UserID (int), Role (string) What I want is for my "User" class in my domain to have an IList of roles. How do I construct my Fluent NHibernate mapping to achieve this? ...

NHibernate Mapping Issue (I think)

Ok, so I have an object named "Business" (I know, I know, "Business Business Object") When it saved its foreign keys are getting lost somehow. Everything else is saving. I have stepped through the code and followed the object up until the session.SaveOrUpdate(businessObject); method. The object at that point is intact and the foreign ...

Is it possible to use private field conventions for Fluent NHibernate Automapping?

How can I map to a private field with fluent NHibernate AutoPersistenceModel? public class A { private List<B> myField; public A() { myField = new List<B>(); } public IList<B> MyBs { get { return myField; } } } Is there a fieldconvention for...

Cascade delete from collections in multiple entities

I have three entities: Customer, Device and LocationTag. Customers have a list of LocationTags (nothing more than an ID and a Description). They also have a list of Devices. Devices are tagged with a subset of the Customer's LocationTags, so Devices have a List of LocationTags, too (but only of the Customer's). If I delete a Locat...

NHibernate - Mapping a String Foreign Key

The legacy database I've inherited contains the following tables: Teams ( TeamId INT PRIMARY KEY, Name VARCHAR(30) ) Players ( PlayerId INT PRIMARY KEY, Team VARCHAR(30) ) The foreign key in the players table refers to the team name, rather than teamId. I've attempted to map from Team to Players using a bag: <bag name="Players...

How to create composite UNIQUE constraint in FluentNHibernate?

I know that I can Map(x => x.GroupName).WithUniqueConstraint() for a single property. But how do create a composite unique constraint in fluent nHibernate (where the unique constraint operates on the combination of two columns)? ...