nhibernate

Best way to store enum values in database - String or Int

Hello there, I have a number of enums in my application which are used as property type in some classes. What is the best way to store these values in database, as String or Int? FYI, I will also be mapping these attribute types using fluent Nhibernate. Sample code: public enum ReportOutputFormat { DOCX, PDF, HTML } pub...

Map List<Int32> using Fluent Nhibernate

Hello there, I need to map List<Int32> using Fluent Nhibernate. Sample code: public class ReportRequest { public List<Int32> EntityIds { get { return entityIds; } set { entityIds = value; } } } Please guide. Thank you! ...

How to troubleshoot a schema issue in Hibernate?

I'm playing with Hibernate a little bit. I created a "Group" class and a XML schema tied to it. Unfortunately when I try to export that schema, my .NET complains about a syntax error. I'm pretty sure my schema is malformed, but is there any technique to help troubleshooting ? My XML schema looks like this: <?xml version="1.0" encoding=...

How do I map class like Types<Type> in NHibernate ?

I have a need for specialize collection of custom types in my Domain Model. public class Foos : List<Foo> { } Is there a way to map this object in NHibernate and how could I use FluentNHibernate to do this as well ? ...

NHibernate Fluent and named Queries

Hi there, I am using Nhibernate with fluent. Now I want to call some Stored procedure and use named Queries. I created some xml: <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping> <sql-query name="CleanAppendicesHierarchies"> exec intf_CleanUpAppendixHierarchy </sql-query> </hibernate-mapping> FluentConfiguratio...

Fluent NHibernate Bidirectional Mapping - results in two similar referencing columns

Hello there, I am trying to implement Bidirectional Mapping with Fluent NHibernate Mapping. Code snippet from Domain classes: public class Template { public virtual int? Id { get; set; } public virtual string Title { get; set; } public virtual TemplateGroup TemplateParentGroup { get; set; } } public class TemplateGroup ...

Help with database schema for 50+GB DB

Hi all, I have a task to store large amount of gps data and some extra info in database and to access it for reporting and some other non frequent tasks. When I recieve a message from gps device it can have variable number of fields. For example Message 1: DeviceId Lat Lon Speed Course DIO1 ADC1 Message 2: DeviceId Lat Course DIO2 ...

How to project only two columns and list them? (Nhibernate)

Given the table structure below, how do you project x and y only with nhibernate? How do you list the results, what is the type of the resulting list? //Table structure, mapped in the traditional way FunnyTable { x [int] NOT NULL, y [int] NULL, z [int] NOT NULL } //assume criteria is...

Is it possible to map a composite key in fluent nhibernate where half of the key is an identity field in the database?

As the question states, is it possible to map a composite key in fluent nhibernate (or non fluent i suppose) where one of the two fields used in the composite is an identity field? I have a table where one part of the primary key is an identity field and the other is a tenant id. This is a legacy database where the composite key is used...

NHibernate: mapping single column from many-to-one to a primitive type

I have a following mapping: <set name="People" lazy="true" table="ProjectPeople"> <key column="ProjectId" /> <composite-element class="PersonRole"> <many-to-one name="Person" column="PersonId" cascade="save-update" not-null="true" /> <many-to-one name="Role" column="RoleId" cascade="save-update" not-null="true" /> </compo...

NHibernate: SaveOrUpdate by <natural-id>

Is there an easy way to make NH INSERT or UPDATE an entity depending on whether there is already an entity with same <natural-id />? The entity is mapped to another (root) one using <many-to-one cascade="save-update" />. ...

Using NHibernate Identifier Identity Generator

i have read in more then one place that using NHibernate's Identifier as Primary Key is considered a bad practice because the id are generated at the server side and hence we need a reply from the server about the generated ids. (i think that i have also seen a post by Ayende that says that ms-sql server may have problems generating iden...

NHibernate Current Version

What is the current "production ready" version of NHibernate? I get conflicting answers on the hibernate site vs some other posts. Is it 2 or 2.1?? If it's 2.1 where do I get that binary? ...

Nhibernate will not delete child from collection

First the mapping... <set name="Comments" table="cm_events_venue_comment" inverse="true" lazy="true" generic="true" cascade="all-delete-orphan" batch-size="10" order-by="dateCreated ASC"> <cache usage="read-write" /> <key column="venueId" /> <one-to-many class="VenueComment" /> </set> A passing test.. ...

rhino.commons unit of work

Hi i'm trying to get multi tenancy working in my app - using nhibernate integration facility from castle and i think that the funky combination of using the nh facility combined with fluent is making the task of configuring more than one session factory a pain. i'm thinking about swapping it out to use the rhino.commons UoW implementat...

What are the differences between HasOne and References in nhibernate?

What are the differences between HasOne() and References() in nhibernate? ...

ActiveRecord Query (Castle, Performance)

I've 3 tables: Parts: Name: internal name, Active: bool Languages: list of languages (English, French, German, ....) PartsTranslations: RealName and Id's of the other 2 tables. I would like to get a list of Parts telling me the internal name, active status and how many translations are missing (total lang subtract translations made)...

NHibernate executing extraneous select statements

Problem When executing a get for an entity with a many-to-one relationship with outer join set to true, not-found set to ignore and the entity row on the one side does not exist, an extra select is executed by NHibernate trying to load it even though the previous select which was just executed could not find it. Question Why is this e...

Discriminated unions in NHibernate

I'm wondering if there's any relatively easy way to extend NHibernate to support F#'s discriminated union. Not just a single IUserType or ICompositeUserType, but something generic that I can re-use regardless of the actual contents of the DU. For example, suppose I have a property called RequestInfo, which is a union defined as: type R...

Nhibernate-Linq: How can I use Iqueryable list after session close?

Is it possible to get list after Session.Close as below? var bundles = session.Linq<Bundle>(); session.Close(); var bs = bundles.ToList(); I get error, is there a different syntax for that? ...