nhibernate

NHibernate IList to List

Hi I am trying to return a collection of building domain. private long _id; private string _buildingName; private IList<BasicRoom> _rooms; I am using NHibernate and this mapping for the rooms <bag name="rooms" table="tb_rooms" lazy="false"> <key column="buildingID"/> <one-to-many class="Room"/> </bag> And I am calling the db like t...

How does TransactionScope roll back transactions?

I'm writing an integration test where I will be inserting a number of objects into a database and then checking to make sure whether my method retrieves those objects. My connection to the database is through NHibernate...and my usual method of creating such a test would be to do the following: NHibernateSession.BeginTransaction(); //...

nHibernate 2.0 - mapping a composite-id *and* many-to-one relationship causes "invalid index" error

I have a problem. Imagine this data model: [Person] table has: PersonId, Name1 [Tag] table has: TagId, TagDescription [PersonTag] has: PersonId, TagId, IsActive Since [PersonTag] isn't just a simple many-to-many join table, i have all three entities created in nHibernate (exactly like they are in the data model). PersonTag, therefor...

Persisting Blob Streams with NHibernate

If I have a class declared as: public class MyPersistentClass { public int ID { get; set; } public Stream MyData {get;set; } } How can I use NHibernate's mappings to persist the MyData property to and from the database? ...

How do you map a component that is also a primary key in NHibernate hbm xml (or in a fluent-nhibernate class map)?

I'm trying to figure out how to map a component as a primary key in nhibernate and if possible in fluent nhibernate as well. The component in question is a unique set of 3d coordinates, here's the object: public class SpaceLocation { public virtual SpaceCoordinate Coordinates { get; set; } public virtual SpaceObject AtLocation...

Filter child collection using a child collection of the child

Err, I can't think of better title. Basically I have a class called MarketGroups, this has a child collection Markgroups that has a collection of MarketTypes and MarketTypes has a collection of MetaGroups. I would like to be able to, in one query, load the Parent, and only return Child MarketGroups that have MarketTypes with one specif...

How can I query a SQL 2005 XML field with NHibernate?

My Microsoft SQL Server 2005 database contains a table that has an XML field that has some important metadata, and under normal SQL I could run the following query and get a list of items which don't have UPC codes set... Unfortunately I'm having a hard time re-creating this query using NHibernate's Criteria API: SELECT [Id],[meta].valu...

NHibernate Bag Mapping

Hi I need a hand mapping a collection. I am using a join table to hold references to rooms ids and calEvent Ids. However, the look ups will mainly be based on the room's buildingID - so I'd like to add buildingID to the following mapping. Does anyone know how to do so. I've looked through the NHibernate docs but can't find anything. <b...

Nhibernate Datetime issues

hi there, i'm currently experiencing a little problem. I'm using nhibernate with around 40 entities mapped to a sql server database. however, due to performance reasons some operations are done via stored procedure. i have a stored procedure that takes 3 parameters. one entity ID and 2 DateTime's. now, when i have a Date like the 10th...

NHibernate mappings for 2 classes that have multiple relationships

I get the following error when attempting to use NHibernate to persist a new instance of 2 objects that have more than one association between them: NHibernate.Exceptions.GenericADOException: could not insert: [MyProject.BusinessEntities.Client][SQL: INSERT INTO dbo.Client (Version, CurrentEvent_ClientEvent_Id, EntityType, Id) VALUES (...

NHibernate - WHERE EXISTS(X)

I have the following tables (simplified): Product(Id, Name) OrderItem(Id, ProductId) ...which map to the following classes: Product {Id, Name} OrderItem {Id, Product (many-to-one)} I need the (N)Hibernate syntax to retrieve the Products that appear in Orders. The SQL would be something like: select * from Product where exists (...

T4 template for NHibernate? - not Fuent NHibernate

Wondering if anyone knows of a set of T4 templates for generating C# POCO classes and also mapping XML files for NHibernate from a set of tables in a database. I saw that David Hayden has created T4 for generating FluentNH code based upon a DBML model, but I'm not quite ready to use FluentNH yet as there isn't even an official release ye...

NHibernate Session ObjectDisposedException

Is there anyway to verify if a Session has been disposed of by NHibernate? I have a wrapper class on Session that has it's own Finalizer and IDispoable implementation however if the Session gets disposed before I handle it myself in my class I end up receiving an ObjectDisposedException. I really don't wish to wrap my clean up code wit...

NHibernate programmatic mapping file loading with embedded resources

My application supports both Oracle and MS SQL databases, with slightly different schemas having been implemented for each. One issue I've run into is a class that has an auto-increment primary key under MS SQL, but a manually-inserted primary key under Oracle. Right now, the two different mappings for the class look like this: Oracle:...

Fluent Nhibernate mapping inner join on 3 tables

Datastructure is: Table[Questionnaire] the top node Table[QuestionGroup] just a grouping for heading etc Table[QuestionnaireQuestion] mapping [Question]<->[QuestionGroup]s many to many relationship and the [Questionnaire]<->[Question]s many to many relationship Table[Question] One question can exist in many questionnaires/questiongro...

How do you handle Membership/Roles when using NHibernate?

I'm about to kick off a new project using NHibernate and ASP.Net MVC and have come upon the question of membership. I'm wondering if I should use a 3rd party NHibernate Membership/Role provider, create my own, or just skip the providers all together. So far I've looked at: Manuel Abadia's NHCustomProviders - It seems like a lot of conf...

Modelbinding database entities in ASPNET MVC

I'm having trouble trying to think what the best way is to recreate a database object in a controller Action. I want to make use of ModelBinders so in my action I have access to the object via a parameter, rather than having to repeat code to get an object from the database based on an identifier parameter. So I was thinking of having a...

SimpleDB dialect for NHibernate

Do you know if there is a way of using Amazon SimpleDB with NHibernate? LightSpeed seems to be compatible. ...

NHibernate - join without mapping

Hi, Is it possible to join two classes without specified mapping between them (using Criteria API)? I must join two classes and retrieve data from both but I can't mapping them. I know only foreign key SomeID in the first class and primary key ID in second. How to create Criteria to join them? Is it possible without mapping? Please, ...

How to use Nhibernate with variable or dynamic table names like Jan08Tran,Feb08Tran,Mar08Tran

I have legacy database in which transaction tables are stored by monthly names. eg. Jan08Tran Feb08Tran How can I use NHibernate to work with this tables? Read a bit about entity-name property, SubClass etc. But not able to find concrete solution. ...