nhibernate-mapping

why doesn't NHibernate FetchMode.Join work in this scenario?

I have two entities, C and P. C is mapped to P in a one-to-one association, with lazy="no-proxy", like this: (P's mapping:) <one-to-one name="c" class="C" property-ref="P" access="field" lazy="no-proxy"/> P is mapped to C in a many-to-one association, like this: (C's mapping:) <many-to-one name="p" column="PId" class="P" access="fiel...

displaying address on pin drop in map

Hi, Currently in my map code pin is dropping at current location and on pin click address is displayed. I want to display address without user interaction. How to do it? ...

Error mapping UserType from to property with NHibernate

I needed a way to trim strings within my persistent class because my legacy database is using char fields. I downloaded the nHhaddIns dll to use its TrimString class which is derived from IUserType. Using their example I created a property in my mapping class as shown at the bottom. uNHAddIns is added as a project within my solution. H...

Nhibernate: mapping two different properties between the same 2 entities

I have a Class A: public class ClassA { public int ID {get; private set;} public string Code {get; private set;} public ClassB B {get; private set;} public IList<ClassB> ListB {get; private set;} } And a ClassB: public class ClassB { public int ID {get; private set;} public string Code {get; priva...

Fluent NHibernate DiscriminateSubClassesOnColumn Issue

I said Fluent NHibernate in the subject, but I think this is an NHibernate question. However, I didn't want to confuse things by leaving out details. I'm using Fluent NHibernate 1.0.0.593 with NHibernate 2.1.0.4000. First a little background... I have a base class with three implementation classes that I'm trying to map using the Di...

SchemaExport vs HiLo algorithm

I'm using schemaExport to create an in-memory database for my automatic tests. I have several (5) classes mapping their HiLo identity to the same database table, using one column per class. This gives me a table, hibernate_unique_key, w. 5 columns. When generating the database using scemaexport, however, the table only gets a single col...

How do I map an optional one-to-one relationship with Fluent NHibernate?

I've got two entities, one called Site and the other called Assignment. A Site may or may not have an associated Assignment. An Assignment is only ever associated with one Site. In terms of C#, Site has a property of type Assignment which could hold a null reference. I have got two tables by the same names in the database. The Assignmen...

Can someone give me a mapping example of two NHibernate classes that have composite keys and one-to-many?

Can someone please give me an example of what the mappings would look like for two classes that both have composite keys and a one-to-many relationship? I have looked everywhere and tried 100 different things with no luck. E.g., HeaderTable -HCONO Decimal -HDVNO Decimal -HDTTK Decimal -HDES2 String -HDESC String -HDESC3 String HCO...

nhibernate Dynamic Insert fails with some null Component properties

I have a database that accepts no null values and has a default for every field. Using fluent nHibernate, I am getting an error on an Insert if I have a component that has some, but not all properties filled out. I am just wondering how to get the DynamicInsert flag down to the component level. Perhaps it is late, but I'll just drop t...

nhibernate help mapping entity with multiple foreign keys

Hi, how would I map this relationship in NHibernate (I'm using the simple idea of the auction example to demonstrate the problem) Database Tables / Entities: User - contains the users Item - an item for sale (like ebay) Bid - records a user's bid on an item I was imagining the bid table to look like this with: Id (PK), ItemId (FK), Us...

Mapping an immutable structure as a component in NHibernate

I'm testing out NHibernate to be the solution to my company's ORM needs. To do this, I've produced a small test model based on a school, providing some useful edge-cases for NHibernate to handle. I'm having problems finding out how to map a custom structure as a component of an entity without using theIUserType interface. I should stres...

NHibernate fetching the superclass brings the subclasses along

Hi, i have this code to get a ClassA from the database, and ClassA is superclass of ClassB. (ClassB : ClassA) var query = from classA in GetQuerySession().Linq<ClassA>() where classA.Code.Equals(code) select classA; return query.FirstOrDefault(); ClassA and ClassB are mapped to ...

NHibernate mapping - how to achieve this

Hello! I have been trying for quite a while to work out how to accomplish my mission, and in fact I am not even sure that the direction I am heading in, is indeed a diserable one in terms of my SQL tables - but it is the most concise I have been able to think up on. My problem is fairly simple to describe. I have a table containing com...

Question about retrieving (sort of) unmapped entity in nhibernate

I have a custom CMS implementation where each article can be linked to a list of tags. the nh mapping for this part looks like this: <bag name="Tags" lazy="true" table="CMS_Articles_Tags" cascade="all-delete-orphan" batch-size="10"> <key column="article_id"/> <element column="tag" type="string"/> </bag> the rest of the mapping is ...

Nhibernate doing updates on select?

Hi, I have the following class: public class Product { public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual Decimal PricePerMonth { get; set; } public virtual BillingInterval DefaultBillingInterval { get; set; } public virtual string AdditionalInfo { get; set; } } and the mapping look...

How to create a tagging system with NHibernate (many to many)

I'm learning NHibernate and hoping you guys could help me a bit about Tag Cloud design and solutions. I have 3 tables which are "News", "Tags" and "News_Tags" with Many-To-Many relationship and the "News_Tags" is the link table. Options: cascade="all", cascade="all-delete-orphan" If I delete one of the news records, the it will delet...

mapping System.Version with NHibernate 1.2

I've got an object that uses System.Version as a property. I want this object to be mapped into my table, storing the version as a string. what's the best way to go about doing this with NHibernate v1.2? public class MyClass { public Version MyVersion {get; set;} } not sure what to do with the propery mapping <property name="MyVers...

Does this inheritance design belong in the database?

=== CLARIFICATION ==== The 'answers' older than March are not answers to the question in this post! Hello In my domain I need to track allocations of time spent on Activities by resources. There are two general types of Activities of interest - ones base on a Project and ones based on an Account. The notion of Project and Account hav...

How do you delete a referenced object when the reference changes in NHibernate?

I have two entities like so (distilled to only what's relevant): public class Person { public virtual Address Address } public class Address { } Person has a many-to-one relationship with Address, or in object terms, a Person references an Address, and this link is uni-directional (Address does not have a reference back to Person...

(Fluent) NHibernate composite-id problem : MySQL complains that the parameter index is out of bounds

I'm using Fluent NHibernate to create an ASP.NET MVC project, with Submissions and Votes (Up/Down) by Users. Of course, Users can vote submission Up or Down. To record this, I created a middle table, SubmissionVote, which contain the following fields: submissionId (int) userId (int) score (enum: up/down) Here are my mappings: Submis...