nhibernate

Datacontext and Nhibernate Session

I am a newbie to Object Oriented Programming. I am working with Windows Application and Model View Presenter Pattern and I want to have the Change tracking available. My question is as follows Do I need the presenter to hold a Nhibernate Session or Linq to Sql Datacontext for my Unit Of Work? Is this the simplest way I can architect a W...

How to configure Nhibernate in ASP.Net

Hi there! I am a beginner in ASP.Net. I am starting a new project using ASP.Net and Nhibernate. I figured out that the hibernate.cfg.xml would not do the trick for the configuration of Nhibernate. I googled for on how to configure NHibernate in ASP.Net and this is simplest that I got but I can't get it to work. I also downloaded some pro...

Hibernate session / transaction design

Hey, I'm trying to figure out how to best use Sessions in (N)Hibernate. I have a C# remoting object (MarshalByRefObject) which gets consumed by an ASP.NET client. Currently my remoting class opens up one Session instance in the constructor and uses that one for all transactions. Is this a good idea? And would I need a finalizer for the ...

How to map this model

Hello: A TimeSheetActivity class has a collection of Allocations. An Allocation is a value object (immutable) looking something like this: public class Allocation : ValueObject { public virtual StaffMember StaffMember { get; private set; } public virtual TimeSheetActivity Activity { get; private set; } public virtual DateTi...

NHibernate inheritance question

Hi, Currently I have the following classes: class Article with properties id, title and body class Question : Article with an extra PostedBy property Then I have a table called Article with the above properties and a table called questions with an ID a foreign key articleID and a PostedBy. Both are in different schemas I would like t...

nhibernate newbe question ... easy one here

Hi all, I'm new to nhibernate so this should be easy. I have a mapping file as below although I deleted some fields that aren't relevant to this question. The streamfields class contains a bag of fieldmappings. I want the join to be on field_no column but the sql that is sent is on the id field (str_fld_id") as seen below. I see what t...

NHibernate many-to-many mapping

Hi, I am having an issue with many-to-many mapping using NHibernate. Basically I have 2 classes in my object model (Scenario and Skill) mapping to three tables in my database (Scenario, Skill and ScenarioSkill). The ScenarioSkills table just holds the IDs of the SKill and Scenario table (SkillID, ScenarioID). In the object model a Scen...

database inspection while debugging

I am trying out some cascade options with nhibernate mapping and have a unit test where I'd like to use a tool to inspect the state of the database. I was hoping I could use linqpad to do this, but the connection seems hung while in the debugger. I'd seen a demo not to long ago where SSMS was being used to inspect the db during a debug, ...

Using Linq Expressions to decouple client side from DAL (which is server side)

Hi folks. I could not find the answer amongst the many posts on Linq, so here I am. We have a client-server application, where the client side has absolutely no knowledge of the actual DAL on the server side, which is incidentally implemented using NHibernate. Meaning, there is no references to NHibernate from the client side assemblies,...

How to tell NHibernate to map one-to-many relationship to List<T> and not IList<T>?

Hi! Can I somehow tell NHibernate to map my one-to-many relationship to a property which is of type List instead of the interface IList? I know that NHibernate uses its own IList-implementation for lazy loading, but I don't need this feature. Instead I need a class that is serializable, which I cannot accomplish by using the IList inte...

How to know if a WCF DataContract represents a persistent or transient entity?

If you don't want to expose the ID of a domain object to the client of a WCF service, you would obviously not put an ID property in the DataContract, right? But then, when the client calls the save method on your service, how do you know it's a new object, or an existing one that was modified? With NHibernate you can use SaveOrUpdate an...

Nhibernate.Search, Lucene, and the Criteria API: types mismatch

Update I've been looking around the NHibernate.Search.Tests project to find out how the Criteria API is used (i find it immensely useful to look around the test code to have working examples) and i noticed that the way to use the Fulltext search is radically different. Here are two tests, one with the criteria API, one with the classic ...

Need help in cascade='delete'

Hi guys, I don't know whether this question has been asked before or not. But i was trying to use cascading delete, but couldn't find enough documentation to get my answers that is why Im asking here. I have one parent class and two child classes dependent on that. When i delete parent it should delete the other two child classes as wel...

Creating Oracle Text Index using NHibernate

Hi all, I have been playing with NHibernate (especially Fluent NHibernate) for couple months. I really like it and appreciate people who contribute to those projects. I am trying to create an Oracle Text Index using NHibernate, but I couldn't get this to work. session.CreateSQLQuery("create index MYSCHEMA.NAME_TEXT_INDEX on MYSCHEMA...

Using Fluent NHibernate Auto Mapping to map IDs of type object from base Entity class

In the project I'm working on now, we have base Entity class that looks like this: public abstract class Entity<T> where T : Entity<T> { public virtual object Id { get; protected set } // Equals, GetHashCode overrides, etc... } Most classes inheriting from Entity should map Id to int column in SQL Server database, but at l...

Strategies for Fixing Problems / Tweaking NHibernate Apps in Production

First off, I am not a DBA, but I do work in an environment where DBAs do tune/make changes in the production database from time to time in ways that do not cause the need for an application rebuild/redeployment. Usually these changes consist of reworking indexes, changing procs, and sometimes changing the table structure in minor ways (u...

Invalidcastexception error while using set or bag cascading

Hi guys, I have a parent class which contains a child object. I am using set to save the child object when parent is saved. I m not sure whether set is used for just saving a child object. And im getting this error below System.InvalidCastException: Unable to cast object of type 'x' to type 'Iesi.Collections.ISet' Does anybody knows th...

Problem with saving chinese character into oracle using NHibernate

I am trying to save chinese character into oracle DB using Nhibernate thru C# and the character saved always end up with some rubbish character. I have done the following: Hbm mapping for the field is declared as type AnsiString and column type as sql-type="nvarchar". Have also tried String and nvarchar2 too. Database column data typ...

How to map this using Fluent NHibernate

Here is an example of my class: public class ClassX { private ClassY _y; public ClassY PropertyA { get { return _y ?? (_y = new ClassY(this); } } } public class ClassY { public virtual string PropertyB { get; set; } } My table looks like this: table ClassX { PropertyB varchar } So I need PropertyA to be cons...

How do I call a stored procedure from NHibernate that has no result?

I have a stored procedure that logs some data, how can I call this with NHibernate? So far I have: ISession session = .... IQuery query = session.CreateQuery("exec LogData @Time=:time @Data=:data"); query.SetDateTime("time", time); query.SetString("data", data); query.?????; What should the method ????? be? Or am doing something more...