nhibernate

Nhibernate: <map> and <many-to-any>

What I do wrong? <map name="Aspects" table="AspectToEntity"> <key column="EntityID" /> <map-key column="AspectName" type="string" /> <many-to-any id-type="long" meta-type="string"> <column name="AspectName" /> <column name="AspectID" /> </many-to-any> </map> Exception: Repeated column in mapping for collection: Entit...

Mapping interface or abstract class component

Please consider the following simple use case: public class Foo { public virtual int Id { get; protected set; } public virtual IBar Bar { get; set; } } public interface IBar { string Text { get; set; } } public class Bar : IBar { ...

Why use IDictionary for Child Classes for NHibernate ?

As I read here http://www.theserverside.net/tt/articles/showarticle.tss?id=NHibernate for example public class Department { private int id; private string name; private IDictionary classes; private IDictionary professors; } Why not use Generic List ? ...

Calling a store procedure with nHibernate

How do you call a stored procedure with nHibernate? Specifically there are two cases where I am using store procedures: to return a scalar value and to return a set of results mapped to entities. ...

NHibernate: Or-clause with Components

Hello! I have two classes: public class Person{ public virtual string Name { get; set;} public virtual Address Address { get; set; } } public class Address{ public virtual string Street { get; set; } } Now I want NHibernate to give me all Persons where Name is equal to "Xyz" or Address.Street is equal to "Xyz". This approach...

NHibernate: HasMany components and Where/Contains clause

Hi, I'm trying to work out how to create a query using Linq to NHibernate. I have two classes like this: public class Foo { private ISet<Bar> _bars = new HashedSet<Bar>(); public virtual ISet<Bar> Bars { get { return _bars; } set { _bars = value; } } } public class Bar { public string Name { get; se...

NHibernate: Change from lazy=true to fetch=join brings back the world

hi all, I have a User object/mapping in my application. Each user has a list of contact information (phone, email etc) the mapping for the user contains: <bag name="ContactInfo" table="contact_info" lazy="true" cascade="all"> <key column="contact_id"/> <one-to-many class="...ContactInfo, ..."/> </bag> this works fine but i g...

Using NHibernate Collection Filters with DDD collections

I am trying to map a domain model in NHibernate. The domain model is implemented with what I think is DDD style. The mapping works mostly but then when I try to use a collection filter on an a collection I get an exception which says: The collection was unreferenced. I know the problem comes from how I've implemented the collection. My ...

how to debug a NHibernate mapping?

I use NHibernate (2.0.1GA) with my project. At runtime I get the Invalid Cast (check your mapping for property type mismatches); [...] So it only says its unable to cast something. Thats a bit unprecise imho. My mapping file is pretty big (master table with about 50 colums plus 11 subsets). How do I find the invalid cast without ch...

Can I append pieces of custom HQL when using NHibernate's criteria api?

Hi! Normally I'm using criteria api to make queries against my database, but because criteria api seems to have a bug when searching for the same entity twice, I would like to append a custom piece of HQL to the rest of my criteria. Is this somehow possible? Here is an example of what is not working with criteria api: public class Per...

Help..! NHibernate CreateSQLQuery Transaction Issue...

I have a simple method that does... Session.CreateSQLQuery(syntax).List<T>(); The issue is that when I execute this against a stored procedure that enlists a linked server connection I get the following error... The operation could not be performed because OLE DB provider "MSDASQL" for linked server "MyLinkedServer" was unable to beg...

How do you check if a table exists with NHibernate(or Fluent)?

Whats the best, most consistent way to check if a table exists in NHibernate (or with Fluent-Nhibernate)? Is it even possible? I mean it seems like a simple task for such a heavy-duty ORM. Also on a related question, can you check if a set of tables or a whole schema exists with NHibernate? ...

First level cache doesn't update when using FetchMode.Join

Hi, I'm having a problem with the first level cache in NHibernate in our web application. In our application we have a context based session that is alive during each request (opened on request start and closed on request end). In addition to this we have a model structure with User, Organization and OrganizationType such that each Use...

Merging entity changes in Nhibernate

Given I have a scenario where two users are editing different address object at the same time.* User 1 edits address.streetname only and saves and User 2 edits address.town and saves. Is there anyway I can configure nhibernate so that only the changed fields are updated and thus the changes are merged? I have tied dynamic-update, but ...

Could not load file or assembly NHibernate

I recently had some problems with the hibernate.cfg.xml as I hadn't had the following line in <property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property> Now that this is fixed I am being shown the following error: Could not load file or assembly 'NHibernate, Versi...

Log4net Not Creating Log File For NHibernate

Hi, This is my first serious project using NHibernate and I have setup log4net to output the sql generated by NHibernate but after running my web app I cannot find any log files. This web app is currently being run on my local machine with http://localhost/dispatch. The dispatch directory is a virtual directory in IIS pointing to a pro...

NHibernate - Multiple Database Mappings in 1 Class

Hey, Sorry if this seems a little crazy but ive been messing around with NHibernate for a while and have come accross a scenario that may not be possible to solve with NHibernate... I have 1 database that contains a load of static data, imagine it like a huge product lookup database, just to point out this is an example scenario, my ac...

NHibernate map foreign key

I have two tables, Vehicle and Make. The two are joined using the MakeId as a foreign key on the Vehicle table. My mapping file looks similar to this <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Demo.Business.Objects.Vehicle, Demo.Business.Objects" table="V...

nHibernate (fluent) and many to many mappings with extra metadata

I am trying to work out how to manage the following relationships A Store has many Products A Product is in many Stores A Store knows how many of each Product it has In the database I have 3 tables Stores, Products and a StoreProducts that has StoreId, ProductId and Quantity. How would I map this in nHibernate or fluent nHibernate? ...

NHibernate transactions randomly not rolled back

I have a suite of integration tests that run inside transactions. Sometimes it seems that NHibernate transactions are not being correctly rolled back. I can't work out what causes this. Here is a slightly simplified overview of the base class that these integration test fixtures run with: public class IntegrationTestFixture { priva...