nhibernate

Nhibernate inserting with values on a bag

I am using a where clause on a bag to filter a bag. Is there any way to make nhibernate insert these filter values into the database? ...

NHibernate Query

Is it possible to get NHibernate to generate a query similar to the following with HQL or Criteria API? select * from ( select row_number() over ( partition by Column1 order by Column2 ) as RowNumber, T.* from MyTable T ) where RowNumber = 1 I can get it to execute the inner select using the formu...

One-to-one Mapping issue with NHibernate/Fluent: Foreign Key not updateing

Summary: Parent and Child class. One to one relationship between the Parent and Child. Parent has a FK property which references the primary key of the Child. Code as follows: public class NHTestParent { public virtual Guid NHTestParentId { get; set; } public virtual Guid ChildId { get { return ChildR...

How to configure database connection securely

Similar but not the same: How to securely store database connection details Securely connecting to database within a application Hi all, I have a C# WinForms application connecting to a database server. The database connection string, including a generic user/pass, is placed in a NHibernate configuration file, which lies in the same ...

How to use Linq with Castle ActiveRecord

I am playing around with Castle ActiveRecord and noticed that the download included the file, Castle.ActiveRecord.Linq.dll. I haven't found any documentation for using Linq with ActiveRecord, only some old blog posts. What is the usage pattern? Is Castle.ActiveRecord.Linq ready for production use? ...

how to delete fk children in nhibernate

I would like to delete the ICollection PriceBreaks from Product. I'm using the following method. However they dont seem to delete. What am i missing. When i step thru. i notice that "product.PriceBreaks.Clear();" doesn't actually clear the items. Do i need to flush or something? public void RemovePriceBreak(int productId) { using (...

NHibernate CreateCriteria and CreateQuery generates different sql ?

I'm new to NHibernate and can't figure out why these two statements generates different sql. the first one only get the ClientInformation (with Information and Client being Proxies) which is what i want. return repository .CreateQuery("from ClientInformation ci where ci.Information.IsMandatory = true and ci.Client.Id = :cl...

Fluent Nhibernate external configuration

Hi! All examples of fluent nhibernate make such(or similar) call: c.AddMappingsFromAssembly(typeof(Product).Assembly); I don't want tu use "typeof(Product).Assembly" as i don't want to have reference to my domain project here ("Procuct" class). In ordinary NHibernate I would just create hbm.xml files and make following entry in web.co...

NHibernate will not insert a record

I have an application that is now 4+ years old that is exhibiting some odd behavior on our latest deployment. The application uses nHibernate for all inserts / updates / selects, etc. We are currently using .NET 2.0, and nHibernate 1.2 (I know, we need to upgrade) This deployment is on Windows 2008 Server x64, IIS 7.5 - what I have see...

Ordering by formula fields in NHibernate

Suppose that I have the following mapping with a formula property: <class name="Planet" table="planets"> <id name="Id" column="id"> <generator class="native" /> </id> <!-- somefunc() is a native SQL function --> <property name="Distance" formula="somefunc()" /> </class> I would like to get all planets and orde...

How to get the NHibernate ISession that is HttpContextScoped by StructureMap.

Hi all I'm somewhat new to the MVC framework and in accordance with the following post: NHibernate with StructureMap I am not sure how to actually get the HttpContextScoped ISession in my controller? I'm sure there is a simple way to do this but I am unsure. Also, it's a small project and I don't want to go overboard with Enterprise D...

Call NHibernate Repository from HttpApplication.Init()

In S#Arch based web application I need to read some data during the application initialization. From the first point, the best place - HttpApplication.Application_Start() or HttpApplication.Init() But, Application_Start isn't applicable as there is no WebSessionStorage yet. Init() seems isn't fit as well, as there is no NHibernateSessio...

nhibernate : Repository Session Management

At the moment my repository has 2 constructors. When i call these from my mvc website i am alway calling first constructor and thus opening a new session. Should i been passing in the session. How should i be doing this. public CompanyRepository() { _session = NHibernateHelper.OpenSession(); } public CompanyRep...

INamingStrategy being ignored by (Fluent) NHibernate?

I am trying to write a naming strategy for NHibernate that will prefix table names based on what assembly the poco is defined in. Right now my strategy is just trying to append any prefix at all to the tables just to prove I have things wired up right. The problem that I am encountering is that I am able to create my INamingStrategy ...

Nhibernate filter tree permissions

I am trying to create an HQL query that will filter a tree based on a user. On the tree root i have AllowUsers and AllowRoles and on each node I have DenyUsers and DenyNodes. I can filter to on the user on the root of the tree using select e from oStructureMenu e join fetch e.Nodes n where e.Id = :id and :user in (select u from...

How to Combine Castle ActiveRecord entities with normal NHibernate entities?

I am trying to integrate entities defined with ActiveRecord and entities mapped with plain-old .hbm files. I need to have associations between the two, i.e.: ActiveRecordEntity.HbmEntity & HbmEntity.ActiveRecordEntity The only thing I've bumped into that seems at all related is the ActiveRecordMediator but it didn't look like it wou...

Fluent Nhibernate HasMany

I am having a gap in understanding and I would appreciate any help. When I create a HasMany relationship using a list, nhibernate creates an "index" column on my child table. If I query the table using a join, it crashes with "Null Index on collection" What I am not understanding is -- how is this "index" column managed/populated? M...

How to Query Many to Many Objects in NHibernate

Hi, I have two database tables that have a many to many relationship: People and Organization. And of course there is a table that connects these two called OrganizationPeople. In NHibernate mapping, they each have a Bag of the other. In People's mapping, the Bag is mapped like this: <bag name="Organizations" table="OrganizationPeop...

NHibernate: SELECT MAX() with JOIN

I have a Vendor. Every Vendor has several Reservations, with a ReservationDate on it. I want a list of Vendors that have not made a reservation yet today. In SQL I would do something like this: SELECT v.Id, MAX(r.ReservationDate) AS MaxDate FROM Vendor v INNER JOIN DailyReservation r ON v.Id = r.Vendor_Id GROUP BY v.Id HAVING MAX(r....

NHibernate Return Values

Hi, I am currently working on a project using NHiberate as the DAL with .NET 2.0 and NHibernate 2.2. Today I came to a point where I had to join a bunch of entities/collections to get what I want. That is fine. What got me was that I do not want the query to return a list of objects of a certain entity type but rather the result woul...