nhibernate-mapping

how to map in hibernate

hi' I am new to hibernate. I am facing problem at the time of mapping in my table no primary key is there . but two not null values are there how i can represent them in hibernate thanks in advance my table structure is like this Field Type Collation Null Key Default Extra Privilege...

Mapping IList items to columns

I am working with a legacy database that has a table to store up to 5 categories a user has permissions to view: USER_ELIGIBILITY ---------------- Eligibility_Id INT PRIMARY KEY Eligibility_Name NVARCHAR(100) CategoryId1 INT CategoryId2 INT CategoryId3 INT CategoryId4 INT CategoryId5 INT The following is how I have created the class: ...

How to map NHibernate custom collection with fluentNHibernate?

I am trying to map the collection for two days without success. I also read all possible articles and forums but still down there. Ok, here is the problem: 1) The collection class contains a private field "_internalCollection" which is mapped with NHib. 2) The holding entity should expose the collection trough readonly property. 3) I ...

NHibernate not-null attribute has no effect

Hi, I'm trying to add a column to an existing table. I added a property to the mapping : <property name="SelectionId" column="selection_id" not-null="true"/> When I open the session, the new column is created, however the not-null attribute is not taken into account : the new column is nullable. I realize you need to specify a defau...

How to map small binary objects properly in SQLite/NHibernate combo (wrong type affinity)?

Trying to store property of C#/.NET type byte[] in SQLite. Here is my mapping: <class name="MyClass" lazy="false" table="MyTable"> <property name="MyProperty" type ="BinaryBlob" access="property" /> </class> In SQL server it works like a charm even without the explicit type="BinaryBlob" in the mapping. In SQLite I've tried various ...

Unusual? HasManyToMany NHibernate Mapping

Database Strucutre: Shows ID Name Genres ID Name ShowsGenres ShowsID GenresID Above is my Database I am trying to figure out how to map this properly. My Show object is like this: public class Show { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual IList<Genre> Genres { get; se...

Nested Maps in Fluent NHibernate

I have a database table with Sqlite structure: CREATE TABLE Cashflows ( Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Fund_Id INTEGER NOT NULL, CashflowDate DATETIME NOT NULL, CashflowType INTEGER NOT NULL, CashflowValue DOUBLE NOT NULL ); Fund_Id is just a standard reference to the Fund table. In Fluent NHiberna...

Fluent NHibernate Mapping - Composite Key

Hi, I'm trying to map the following tables/entities in FNH and seem to be getting nowhere fast! **Tables** Contacts ID (PK - int - generated) ... PhoneTypes ID (PK - varchar - assigned) (e.g. MOBILE, FAX) ContactPhones ContactRefId (PK - FK to Contacts) PhoneTypeRefId (PK - FK to PhoneTypes) ... (I should...

NHIbernate <any> mapping issue

Hello, I am using NHibernate for an ecommerce site and am having difficulty getting what should be a simple mapping to work. Essentially I have a ContactDetails entity which is used to save contact details for any type of user - Buyer/Seller/Advertiser/etc. I use an "any" mapping to allow a single table to hold contact_details for each t...

NHibernate - Select query in Formula attribute of Property element is not working....

I am new to NHibernate. I am using following property elements in my hbm file... <property name="CountryId" length="4" /> <property name="CountryForCustomer" formula="(SELECT * FROM SystemCountry WHERE SystemCountry.CountryId = CountryId)" /> Here I am trying to g...

Fluent NHibernate: How to map an IList<Dictionary<string, string>>

I would like to have a structure like this: Mapping class int ID {get;set;} IList<KeyValuePair<string,string>> Criteria {get;set;} Criteria class int ID {get;set;} int MappingID {get;set;} string FirstCriterion {get;set;} string SecondCriterion {get;set;} (int index {get;set;}) How can I get this keyvaluepair mapped? I tried with Ha...

How to generate hbm.xml file from FluentNHibernate

I'm trying to follow this tutorial but instead of generating the expected hbm.xml files with my mappings in it generates simple .cs class for my entities like for example: public class ProductMap : ClassMap<Product> But I already defined those myself in code. I'm after the .hbm.xml which I can use in standard NHibernate at this time. ...

How to map Sets when using NHibernate Join Table per Subclass

I have the following HBMs (the sample is purely fictional, so don't try to understand the business needs) Class Document <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Document" discriminator-value="Document"> <id name="Id" type="long"> <generator class="native" /> </id> <discriminator /> <p...

Castle ActiveRecord FK as discriminator column

I have just started using castle active record and i am having some problems using a foreign key as the discriminator column. I get the error "Invalid index 2 for this SqlParameterCollection with Count=2." The tables i am using are:- TABLE MemberRoles [Id] [int] IDENTITY NOT NULL, [Name] [varchar] NOT NULL TABLE Members [Id] [int] IDE...

NHibernate data retrieve problem.

These codes are working well when saving data. But it is unable to retrieve data from b_TeacherDetail-table. For example: TeacherRepository tRep = new TeacherRepository(); Teacher t = tRep.Get(12); Here, t.TeacherDetail is null. But I know that there is an entry in the b_TeacherDetail-table for teacher-id 12. Why? My tables are: T...

NHibernate mapping collection without foreign key

Hi all, I have a class called WorkingDays, this class requires a collection of dates that are the dates of bank holidays. In our database we have a table that contains these dates - I want nhibernate to get all those dates and populate the bankHolidays collection. The catch is however I do not have a table that represents the link in ...

mapping collection type with Fluent NHibernate

Hello guys. I've used Fluent NH in my project but I'm having some problems with using the Collection class. Here's the code for my classes public class Vendor { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Services Services { get; set; } } public class Services : I...

NHibernate.QueryException: could not resolve property

Hello all, I'm using FluentNHibernate and Linq To Nhibernate, with these entities (only the relevant parts): public class Player : BaseEntity<Player> { private readonly IList<PlayerInTeam> allTeams = new List<PlayerInTeam>(); public IEnumerable<Team> Teams { get { return from playerInTeam in all...

NHibernate ManyToMany extra field

Hi All, I have tables JobList, DoList, PlayList, and a lookup table called LegalRequirements I also have a LegalRequirementRelationship as a relation table between the 2, other than the Id of the XXXList and LegalRequirement, I also have a TypeId to identify which of XXXList the line is referring to. JobList,DoList,PlayList all have a ...

how to delete a parent with association to childs of a class hierarchy in nhibernate

I have a class hierarchy - Document as supper-class and Paper, Presentation and Report as sub-classes. I choose table-per-subclass strategy for the mapping. see the mapping bellow: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model"> <class name="Document" ab...