nhibernate

NHibernate ISession Flush: Where and when to use it, and why?

One of the things that get me thoroughly confused is the use of session.Flush,in conjunction with session.Commit, and session.Close. Sometimes session.Close works, e.g., it commits all the changes that I need. I know I need to use commit when I have a transaction, or a unit of work with several creates/updates/deletes, so that I can cho...

Best practices for querying with NHibernate

I've come back to using NHibernate after using other technologies (CSLA and Subsonic) for a couple of years, and I'm finding the querying a bit frustrating, especially when compared to Subsonic. I was wondering what other approaches people are using? The Hibernate Query Language doesn't feel right to me, seems too much like writing SQL,...

How can I map a list of strings to my entity using NHibernate?

I've got two tables in my database: Articles and Tags The Tags tables consist of ArticleID (foreign key) and a Tag (varchar). Now I need to map an articles tags into a readonly collection on Article entity, either using IList Tags or ReadOnlyCollection Tags. I've consulted the NHibernate reference material, but I can't seem to figure ...

(N)Hibernate - is it possible to dynamically map multiple tables to the one class

I have the situation where i use GIS software which stores the information about GIS objects into separate database table for each type/class of GIS object (road, river, building, sea, ...) and keeps the metadata table in which it stores info about the class name and its DB table. Those GIS objects of different classes share some parame...

IQuery NHibernate - does it HAVE to be a list?

Can I return it as an object if I'm doing a Select OneItem from Table Where OtherItem = "blah"? Is there a better way to do this? I'm building a constructor to return an object based on its name rather than its ID ...

NHibernate or LINQ to SQL

If starting a new project what would you use for your ORM NHibernate or LINQ and why. What are the pros and cons of each. edit: LINQ to SQL not just LINQ (thanks @Jon Limjap) ...

How can you do paging with NHibernate?

For example, I want to populate a gridview control in an ASP.NET web page with only the data necessary for the # of rows displayed. How can NHibernate support this? ...

Can you query different databases on the same server using 1 NHibernate Session?

Does a new SessionFactory and Session object have to be created for each database? I have a data store for my application data, and a seperate data store for my employee security, which is used to validate users. Do I have to create a new SessionFactory ans Session object for calls to the 2 different databases? ...

NHibernate.MappingException: No persister for:

Now, before you say it I DID google and my hbm.xml file IS an Embedded Resource. Here is the code I am calling: ISession session = GetCurrentSession(); var returnObject = session.Get<T>(Id); Here is my mapping file for the class: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <cla...

Linq to NHibernate multiple OrderBy calls

I'm having trouble ordering by more than one field in my Linq to NHibernate query. Does anyone either know what might be wrong or if there is a work around? Thanks! Rob Code: IQueryable<AgendaItem> items = _agendaRepository.GetAgendaItems(location) .Where(item => item.Minutes.Contains(query) || item.Description.Contains(query)); ...

NHibernate and shared web hosting

Has anyone been able to get an NHibernate-based project up and running on a shared web host? NHibernate does a whole lot of fancy stuff with reflection behind the scenes but the host that I'm using at the moment only allows applications to run in medium trust, which limits what you can do with reflection, and it's throwing up all sorts ...

NHibernate, Sum Query

If i have a simple named query defined, the preforms a count function, on one column: <query name="Activity.GetAllMiles"> <![CDATA[ select sum(Distance) from Activity ]]> </query> How do I get the result of a sum or any query that dont return of one the mapped entities, with NHibernate using Either IQuery or ICriter...

What is the best way to improve performance of NHibernate?

I have an application that uses NHibernate as its ORM and sometimes it experiences performance issues due to how the data is being accessed by it. What kind of things can be done to improve the performance of NHibernate? (Please limit to one recommendation per answer) ...

Fluent NHibernate Architecture Question

I have a question that I may be over thinking at this point but here goes... I have 2 classes Users and Groups. Users and groups have a many to many relationship and I was thinking that the join table group_users I wanted to have an IsAuthorized property (because some groups are private -- users will need authorization). Would you rec...

When choosing an ORM, is LINQ to SQL or LINQ to Entities better than NHibernate?

I find I can do more with NHibernate, and even Castle than with the Linq to Entities, or linq to SQL. Am I crazy? ...

NHibernate to not cache a property

How can I configure NHibernate to not cache a file. I know I can create a method that does an HSQL, but can I through a configuration setting in the .xml file or the hibernate xml file itself to not cache a property? Thanks in advance. ...

Mapping a collection of enums with NHibernate

Mapping a collection of enums with NHibernate Specifically, using Attributes for the mappings. Currently I have this working mapping the collection as type Int32 and NH seems to take care of it, but it's not exactly ideal. The error I receive is "Unable to determine type" when trying to map the collection as of the type of the enum I ...

Database Authentication for Intranet Applications

I am looking for a best practice for End to End Authentication for internal Web Applications to the Database layer. The most common scenario I have seen is to use a single SQL account with the permissions set to what is required by the application. This account is used by all application calls. Then when people require access over the...

Differences between NHibernate, Castle, Linq - Who are they aimed at?

This answer says that Linq is targeted at a slightly different group of developers than NHibernate, Castle, etc. Being rather new to C#, nevermind all the DB stuff surrounding it: Are there other major, for lack of a better term, SQL wrappers than NHibernate, Castle, Linq? What are the differences between them? What kind of developers...

Books for an ASP.NET Developer moving to Java

Similar to this question http://stackoverflow.com/questions/72719/good-book-for-a-c-developer-going-over-to-java I'd like to know what books mainly targeting web development people would recommend. I'm currently developing large applications with ASP.NET MVC using TDD/DDD (persistence provided by NHibernate, IoC/Application Framework by...