nhibernate

How to implement correctly IUserType?

I need to create a custom type for NHibernate by writing a new mapper class that implements IUserType. While it is relatively straightforward to override most of the methods and properties, I get some difficulties to understand how to deal correctly with the following members: object Assemble(object cached, object owner); object DeepCo...

FullTextSession configuration using spring.net

Am using lucene.net for full text search. Am configuring my Nhibernate session programatically using SearchFactory provided by Lucene in the NHibernate.Search library. Am evaluating if spring.net can be introduced in my system. Am not sure if spring.net will configure a FullTextSession for me? Please let me know if you have any suggestio...

nhibernate.linq simple (read dumb) question

I'm trying to wrap my head around linq -> nhib I have a simple bit of sql that i'm trying to get working in nhibernate.linq select * from ColModel where ColModel.DataIndex not in ('CostElement1', 'CostElement2', 'CostElement3') and ColModel.ReportId = 1 The list of excluded DataIndex values comes in in the form of a List<string...

Nhibernate Fluent domain Object with Id(x => x.id).GeneratedBy.Assigned not saveable

Hi there, I am using for some legacy db the corresponding domainclasses with mappings. Now the Ids of the entities are calculated by some stored Procedure in the DB which gives back the Id for the new row.(Its legacy, I cant change this) Now I create the new entity , set the Id and Call Save. But nothing happens. no exeption. Even NH Pr...

How do the examples in ASP.NET MVC in Action avoid specifying the proxyfactory.factory_class when using NHibernate 2.1

I realize that NHibernate 2.1 removed its dependency on the Castle Project. In fact, Joshua Ewer did a great post summarizing the necessity of a proxy factory for an NHibernate implementation. Presently, I am working through the examples in ASP.NET MVC in Action by Jeffrey Palermo and am confused. The source code examples for both the C...

Save same class structure in two sets of tables with NHibernate

I've got a scenario something like this mock class heirachy Order OrderLine Product Customer OrderNotes which creates some tables like Customer Product CustomerOrderNotes (CustomerId, OrderId) Order (CustomerId) OrderLines (OrderId, ProductId) I've got this mapped to NHibernate and everything is working fine. So now I wa...

NHibernate: How to automatically delete many-to-many associations (cascade)

In my database I've got Users and UserGroups which have a many-to-many relation. The User has a set of UserGroup, the UserGroup domain object does not see the User. <class name="User" table="UserTable"> <set name="UserGroup" cascade="save-update" access="field.pascalcase-underscore" table="User2UserGroup"> <key column="User_...

castle nh facility - 2 databases / 2 models / 2 factories

Hi I have asked this on the castle list as i'm using the nh facility but it just dawned on me to ask it here too :) sorry for the cross posting. I'm using the nh facility to configure the following setup: i have 1 database which stores generic report configuration. and another which stores the actual report data. i also have 1 proje...

NHibernate Many-to-Many Domain Object Properties

Im just starting to work with NHibernate. I've setup a simple many-to-many scenario using Products and Suppliers as follows: <class name="Product" table="Products"> <id name="Id"> <generator class="guid" /> </id> <property name="Name" /> <bag name="SuppliedBy" table="ProductSuppliers" lazy="true"> <key colu...

NHibernate + Criterias + DetachedCriteria

I got this a problem, I need translate this SQL Query to Criteria, but I´m getting some troubles, any one can give a hand? SELECT * FROM Ref INNER JOIN Product Prod on Ref.id = Prod.id_referencia AND Prod.ProdDtAlteracao = (SELECT MAX(Prod2.ProdDtAlteracao) FROM Product Prod2 WHERE Prod.ProdCod = Prod2.ProdCod) ...

Fluent nHhibernate gets but fails to save with 'HasManyToMany'

I have a Resource entity which has a many-to-many relationship with a File entity, such that a resource can reference multiple files and a file can reference multiple resources. Now I expect the save to cascade down from the Resource to the File entities when the Resource is Saved - When I load a Resource entity it is loading the File e...

Storing Nhibernate ISession in Remote object contexts

Im currently building a remote object service that will expose a Server Activated object (per call, not singleton) that uses NHibernate. What i would like to know is there a way to tie a Nhibernate Isession to a .net Remote equivalent to the HttpSession.Context- an ISession per call of my remote object. I have a feeling that a per threa...

NHibernate many-to-one loading alternative?

I have a Parent/Child object/mapping as follows: class Parent { int Id; string name; List children; } <bag name="Children" cascade="all" lazy="false "> <key column="ParentId" /> <one-to-many class="Child" /> </bag> class Child { int Id; Parent Parent; string Name; } <many-to-one name="Parent" column="ParentId" /> O...

how to convert the result in var to DataTable without Loop

How can i convert result in var to datatable without loop? Following is my code:- var result = PhysicianLookUp.Find(Where.PhysicianLookUp.DateTimeStamp.Ge(DateTimeStamp)); ...

nhibernate named queries , name not found

I'm coming from a Java side of using Hibernate and I just haven't found the proper place to put the named query in NHibernate. Using Visual Studio 2008 , C# 2008 I have a query <query name="SchwabAccountList"> from DB_Accounts a where a.AdminOffCode = 'SWB' </query> and I want to put it in the .hbm.xml for the Account table (DB...

NHibernate Inheritance Mapping

I know in NHibernate you can have inheritance mappings, and I know you can have table-per-class, table-per-subclass and table-per-concrete-class but they don't quite fit the scenario I have. Basically what I want is to be able to have a base class called product that looks like this: public class BaseProduct { public virtual int ...

NHibernate is turning my collection readonly. How can I stop it?

Hi guys, I'm having a bit of an issue with Nhibernate / Fluent NHibernate I have a class that has a collection and a backing field, and methods for manipulating the collection like so: Edit: I've added the virtual modifier to Children since I forgot to stick it in the example code below (it was 2 am) public class MyClass { private...

oracle nhibernate connection

Hi, I am trying to connect oracle 10g database through n hibernate, can anyone help me the preliminary steps to be done to establish the connection, I've connected sq l server 2000 easily and its working fine, now i try to connect oracle but i am getting error "cannot open connection". please help me in this regard. Thanks in advance. ...

How to get page number by entity with NHibernate?

I have a paging worked with NHibernate: public IEnumerable<Answer> GetAnswers(int page, int pageSize) { return HibernateTemplate.Execute( session => { var criteria = session.CreateCriteria(typeof(Answer)); return criteria .SetFirstResult((page - 1) * page...

Fluent NHibernate: mapping one-to-one

NHibernate seems to support a special case of one to one mapping (That doesn't require a 1-m mapping on each side of the relationship). See this article by Ayende: http://nhforge.org/blogs/nhibernate/archive/2009/04/19/nhibernate-mapping-lt-one-to-one-gt.aspx I have no idea how to specify this in Fluent NHibernate though - is this pos...