nhibernate

Property with Formula (generated=always) generates invalid SQL for post-insert Select

I'm using NHibernate 2.1CR1. I modified the nhibernate sample from here http://weblogs.asp.net/pwilson/archive/2005/05/26/409042.aspx to work with the new version The class namespace Wilson.NHibernate.Example { public class Contact { private int id; // Database-Generated Key Field private str...

Connect to ESRI Shape File (DBase *.dbf file) from NHibernate

Hi, I've been trying to work out how to connect to an ESRI shape file (which I think is a DBase table file) through NHibernate but haven't had any luck with anything I've tried. Currently, my config's looking like this: <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <!--<property name="...

Simple Query with "OR" clause (Criteria API)

I have this simple query: ICriteria crit = session.CreateCriteria(typeof(Article)); crit.CreateCriteria("Category", global::NHibernate.SqlCommand.JoinType.InnerJoin) .Add(Restrictions.Eq("Name", "Fun")); This is returning all the articles in the "Fun" category. My question is, how can I add a simple OR clause to return also a...

How would nhibernate handle tables that aren't really entities per say?

Hi, I understand how nhibernate would map a table like Users, and Addresses. But what if I have a table like: Users_Addresses with columns UserID, AndressID. Would I have to create a mapping for this and make it like a normal entity? It is really a table that I would reference in a inner join. ...

Help with nHibernate design/ mapping

Hi, I have a pretty simple data model. Article (ID, name, body, date) Category (ID, name, count) Article_Category (articleID, categoryID) Comment (ID, articleID, name, body, date) How would I go about laying out my nhibernate mapping? Also, when I create a new article, it will only have the article and the ID of the category to ass...

Nhibernate: QuerySyntaxException: 'Class' is not mapped

I have the following class: public class MyClass { private List<long> _myList = new List<long>(); public virtual string MyID { get; set; } public virtual string MyData { get { return SomeStaticClass.Serialize(_myList); } set { _myList = SomeStaticClass.Des...

NHibernate session management?

Firstly, let me give a brief description of the scenario. I'm writing a simple game where pretty much all of the work is done on the server side with a thin client for players to access it. A player logs in or creates an account and can then interact with the game by moving around a grid. When they enter a cell, they should be informed o...

SaveOrUpdate Vs Update and Save in NHibernate

What is the difference between SaveOrUpdate and Save/Update in NHibernate. Why wouldnt you just always use SaveOrUpdate? Also, what is the point of SaveOrUpdateCopy? ...

No persister for... {SUBCLASS} NHibernate with Fluent NHibernate

How do I let NHibernate ignore extra properties of a subclass of my model? class SuperModel { // hot I know { public Guid Id { get; private set; } public string FirstName { get; set; } } class SubModel : SuperModel { public string FavoriteColor { get; set; } } I really only want to store the SuperModel data using my repos...

Fluent NHibernate mapping a <map>

UsersTable UserId Name CommentsTable UserId CommentType Comment How to map CommentsTable to a property of User entity??: class User public IList Comments Or public IDictionary Comments hanx I vae to persist CommentType and Comment data to CommentsTable Thanx ...

Parent Child (Save, Update and Delete)

I have a two tables set up as Parent/Child e.g Customer and Address (holding either one record which is both billing and shipping record or 2 records - one billing and one shipping record). Saving a new parent child is not an issue. The issue comes when the user needs to update his details. He has two addresses that he specified when he...

NHibernate Cascade=save-update"?

Hi All, Disclaimer: I am an NHibernate noobie so hopefully this question makes sense. I have a many-to-many relationship between two classes something like… public class Entity1 { public virtual Guid EntityId { get; set; } public virtual IList<Entity2> Entity2List; } Public class Entity2 { public virtual Guid EntityId { g...

NHibernate 2.1.0.4000 doesn't seem to like batch insert

I am using NHibernate 2.1.0.4000 in one of the projects. I have set adonet.batch_size to 100 in the cfg file however I still see that insert statement is treated as single statement. Update seems to work fine. What's going on? Updated: Is it because I've chosen identity as the primary key generator? <id name="Id" column="Id" unsaved-v...

Is there a good documentation of NHibernate's query by example feature?

Hi! I'm trying to find a good documentation which states exactly, what query by example is capable of and what not. In particular, I want to know, if query by example supports a search like the following: I want to get all Persons which have a location with a certain name. public class Person { public virtual IList<Location> Locat...

NHibernate set properties automatically on save

I'm using DDD and NHibernate to persist my domain object. In my database every table that is related to an entity has four extra columns (CreatedBy, UpdatedBy, CreatedDate, UpdatedDate) used for audit tracking. I am using the repository pattern that only allows aggregate roots to be saved. When NHibernate tries to save the entities on th...

Mapping with NHibernate?

I have following classes in my domain model: public class Player { public virtual string ID { get; set; } public virtual string Name { get; set; } public virtual List<Match> Matches { get; set; } } public class Match { public virtual int ID { get; set; } public virtual Player Player1 { get; set; } public virtual...

Using SQL 2008 Change Tracking with NHibernate (modifying the generated DML)

I'm developing an application which requires multiple replicas and uses syncrhonization to keep replicas up to date with each other. To do this, I'm taking advantage of SQL Server 2008 change tracking feature. The one hole in this strategy appears when tracking who made a particular change in a replica. SQL Sever 2008 provides for thi...

How to bind a series of columns into a collection with NHibernate

Please believe me when I say I understand this isn't the "right" way to do this. File this under large-complex-legacy-system questions. We have tables describing OCR'd data of documents. Each document type has its own table. Each table is generated based on the types of fields it expects. So have a schema which looks a bit like this...

fluent nhibernate auto increment non key (Id) property

Is it possible to have an integer property of a class auto increment managed by the database but not be a primary key (or Id as NHibernate refers to them)? I'm having trouble finding examples of how to do this. Any help would be appreciated. Thanks. ...

NHibernate DuplicateMappingException when two classes have the same name but different namespaces

I have a class in my domain model root that looks like this: namespace Domain { public class Foo { ... } } I also have another class with the same name in a different namespace: namespace Domain.SubDomain { public class Foo { ... } } For my mappings, I have a Mapping directory with a subdirectory called SubDomain that contains ...