nhibernate

(Fluent) NHibernate - mapping IList<MyClass> to a single column

Hello. I'm having some trouble to create a mapping. Let's say that persons read books: class Person : Entity { public virtual string Name { get; set; } public virtual IList<Book> Books { get; set; } /* ... */ } class Book : ValueObject { public virtual string Name { get; private set; } public virtual int Pages { ge...

Linq To Nhibernate - Separated queries

Hi all, I've got the following situation: var totalRecords = (from entry in invalidAccEntryRepository select entry).Where(entry => entry.CustomerAccountInfo.CustomerAccountName == CustomerAccountName && entry.CustomerAccountInfo.CustomerAc...

(Fluent) NHibernate Mapping: Use IUserType to Map Custom Class foo - if boo.foo.Id is 0 then write to DB: boo.foo = NULL

Hi there, I have the following construct: class Person { int Id; Foo fooObject; } class Foo { int Id; //some more properties - doesn't matter } the Database is quite simple for this example; Table Person( int Id, int foo_Id) Table Foo( int Id, some more properties...) I often get a Person Object which contains an initialize...

Nhibernate DetachedCriteria Left Outer Join on subquery

Hi! I'll only try to present the main part of the problem, because the whole situation is much more complicated - I am unable to achieve the following with DetachedCriteria SELECT * FROM User LEFT OUTER JOIN GroupItem ON User.ID = GroupItem.UserID AND _groupItemRestrictions_ There can be multiple GroupDefinitions, User can belong to ...

What reasons exist for using NHibernate?

For those people that use NHibernate and similar stuff, why do you use it? To me, it seems easier to write the SQL manually. ...

.NET - ORMs and all possible combinations - ViewModel?

How would you approach this problem with an ORM? This is a hypothetical (simplified) example: I have a table of cities: 1 - New York 2 - London 3 - San Francisco 4 - New Orleans I have a table of scores: (first column Unique Primary Key, second Month Code, third FK to City, fourth Score (int)) 1 - 352 - 1 - 9 2 - 352 - 2 - 10 Fo...

NHibernate long running session for particular domain aggregates in WinForms?

I really don't know what the correct question is to figure out a solution to this problem. So here are some facts to provide context around the problem: Our application is a winforms application that uses NHibernate. Our application is distributed (client calls a service to execute use cases on NHibernate objects). The invoice is the c...

Castle ActiveRecord error "Session is closed"

Hello, I'm trying to get started with Castle ActiveRecord but I'm stuck trying to make it work in an ASP.NET (MVC, if it matters) application. In fact I'm getting an ObjectDisposedException during a query with the following message: Session is closed! Object name: 'ISession'. I'm initializing ActiveRecord from an XML file (as shown i...

NHibernate HiLo - new column per entity and HiLo catches

Im currently using the hilo id generator for my classes but have just been using the minimal of settings eg <class name="ClassA"> <id name="Id" column="id" unsaved-value="0"> <generator class="hilo" /> </id> ... But should I really be specifying a new column for NHibernate to use foreach entity and providing it with a ...

Having issues Running Fitnesse for projects using NHibernate

We are having issues in running Fitnesse for project which uses NHibernate. For all the project FitNesse looks into appropriate folder for getting the dll. For project having reference to NHibernate it errors saying type load exception. Currently we have got it working by copying all the dlls into Fitnesse/dotnet folder. I am sure there...

Nhibernate many-to-one Composite key - if null then fails? is many-to-one or none possible?

Hi Have the mapping as shown below. this is from a leagcy db so have no control over changing the structure. The File record in some circumstances will not have a link to the DISPLAY3 table. Every file has a link to the DISPLAY2 table. However if the File.DISPLAy3 field is null then is does not have a link to the DISPLAY3 only the DISPL...

What's the difference/advantages between ICriteria and ICriterion in nHibernate?

Bit of a newbie question as Im getting started with nHibernate. What's the difference between NHibernate.Criterion.ICriterion and NHibernate.ICriteria classes and which should I use for simple "where field=value" type filtering? ...

Nhibernate - why is it trying to insert existing parent row when inserting child

I don't understand why NHibernate is trying to insert the parent object - when the row already exists in the db - when I'm inserting the child row. Parent mapping: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"> <class name="ReportDistribution.Client.ReportMgr.Model.ClientReport, ReportDistribution.Client.Repo...

Should i decorate my classes/properties as DataContract/DataMember when i use them in WCF?

I have a framework with objects and data access code. This objects are mapped to the database using NHibernate. For example my framework has class Customer and Order: public class Customer { private Guid _id; private string _name; private IList<Order> _orders; public properties... } public class Order { ...

Two classes mapped to same table(one readonly) must be in correct order?

Consider these two classes mapped to the same table. One is readonly via mutable="false". <class name="Funder" table="funder"> <id name="id"> <generator class="identity" /> </id> <property name="funder_name" /> <property name="contact_name" /> <property name="addr_line_1" /> <property name="addr_line_2" /> ...

Automatic Schema Validation using NHibernate/ActiveRecord

Hi, let's assume I have a table of Products with columns: Id, Name, Price and using NHibernate (or ActiveRecord) I map the table to the POCO: public class Product { public virtual long Id { get; set; } public virtual string Name { get; set; } public virtual double Price { get; set; } } Now if someday a new column named ...

NHibernate and generic version

I'm just getting started with NHibernate and reading blogs and articles from all over. many of them reference a session.Get<> methods for generic types, but this is not available for me. I only get the session.Get(Type class, object id) methods. Why is this? Am I missing a reference? Or has this something to do with the NHibernate versi...

How do I get auto-generated SQL statements from NHibernate's operation?

I got a tricky problem. I have to record specified database operations into my database log table. It is a custom table, not relevant to any system database table. It takes the form of SQL statements, but I am using NHibernate as my data access methods. So how do I make it? ...

NHibernate or Fluent NHibernate?

I would be interested in hearing op opinions from others regarding whether which they would choose (no 'neithers' please ;), and why. What are the downsides to using fluent? (version dependancy maybe?) Pros, Cons, Experiences etc. ...

NHibernate custom criterion for an ICcompositeUserType

Hello: Here's a pseudo criteria query I (think) I want to be able to use: public IEnumerable<Allocation> ByResource(ResourceBase resource, DateRange period) { return Session.CreateCriteria<Allocation>() .Add(Restrictions.Eq("Resource", resource)) .Add(Restrictions.IsWithin("MembershipPeriod", period)) .List<...