nhibernate

How to set max return result for many-to-one

Hi, I have a Product Class which has a one to many relationship to a Price class. So a product can have multiple prices. I need to query the db to get me 10 products which have Price.amount < $2. In this case its to populate a UI with 10 items in a page. so i writ the following code: ICriteria criteria = session.Create...

Large applications using NHibernate

Hi guys do any of you working on a large enterprise or web application what uses Nhibernate as an ORM tool ,I interested to know about your experience ? Or maybe you have a link for such an example ? ...

Whats the pros and cons of using Castle Active Record vs Straight NHibernate?

Assuming that writing nhibernate mapping files is not a big issue....or polluting your domain objects with attributes is not a big issue either.... what are the pros and cons? is there any fundamental technical issues? What tends to influence peoples choice? not quite sure what all the tradeoffs are. ...

Use type of object in HQL where clause

In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes like FTPChannelSpecification, EMailChannelSpecification and WebserviceChannelSpecification. Now I want to create an HQL query which contains a where clause that narrows down the result to certain types of channel specifications. E.g. (i...

Removing many to many associations in NHibernate

I have a many to many relationship using NHibernate. Is there an easier way of removing the category association from all products without creating an class for the Join Table? I'd like the SQL to look like DELETE FROM ProductCategories WHERE CategoryId = 123 and here's the code we're using to delete the associations Detach...

nhibernate, class with parents and children causing duplicate keys.

Hi, any help you can give is very gratefully accepted. I've been looking at this problem over and over and cannot seem to find the solution. Its probably staring in me in the face :( I have the following class with a list of parents and children to be persisted in a Hierarchy table. class Item { public virtual int Id {get;set;...

How to a write a Criteria query with multiple joins involved

Hi, I'm trying to code the following HQL query using the Criteria API: var userList = _session .CreateQuery("select u from User u where u.Role.ID=3 and u.Customer.ID=:cID") .SetInt32("cID", 1) .List<User>(); (3 NHibernate objects : User(ID, Name, Role, Customer), Role(ID, Name) and Custo...

Could we have custom name of the primary key column in Fluent NHibernate?

I'm so surprise while I'm working in Fluent NHibernate. I got my legacy database that has primary key column name is different from my property in domain model. I'm sure that I can use this mapping file: <class name="Person"> <id name="Id" column="CommentId"> <generator class="native"/> </id> <property name="Description" typ...

NHibernate - Composite-Id on relation - Where ID of parent is not same composite

Say I have these table in an Oracle database Person: PersonId <- PK ID (int, from sequence) PersonFirstNameID <-- int PersonLastNameID <-- int PersonSecurityID <-- int PersonDetails PersonFirstNameID -CompositeKey PersonLastNameID -CompositeKey PersonSecurityID -CompositeKey PersonDetailKey PersonDetailValue PersonDetailRisk Now I wan...

(N)Hibernate: core/master mappings with relationships

I am starting a job with a mid size company working mostly on writing custom apps that interact with their ERP system. This is my first time doing this sort of work, so the ERP concept is new to me and I am learning it piece meal. I have only written two apps so far and have learned the database model as I went and only as much as I n...

How can i view the mapping configurations passed to the NHibernate by the castle activerecord?

Is it possible to view the mapping configurations / mapping xml files passed from activerecord to nhibernate? ...

Using ActiveRecord/NHibernate, can I Delete and Refresh without a Flush?

I have the following Unit Test method: void TestOrderItemDelete() { using (new SessionScope()) { var order = Order.FindById(1234); var originalItemCount = order.OrderItems.Count; Assert.IsTrue(originalCount > 0); var itemToDelete = order.OrderItems[0]; itemToDelete.DeleteAndFlush(); // ite...

NHibernate SchemaExport with generated properties

I'm wondering if there is a way to get SchemaExport to generate and identity column for a generated property. <id name="Id" column="Id" type="Guid"> <generator class="guid.comb" /> </id> <property name="OrderNumber" column="OrderNumber" type="Int32" generated="insert"/> With the mapping above, ShcemaExport does not make the OrderNu...

How do I setup NHibernate with Visual Studio and Firebird??

I'm trying to set up a small app to experiment with NHibernate in visual studio but I'm not getting far. The error I get is: "Could not find the dialect in the configuration". I've tried specifying settings in both app.config and hibernate.cfg.xml but neither seems to work. These files are in the same directory as my app source (tried...

traversing object graph from n-tier client

I'm a student currently dabbling in a .Net n-tier app that uses Nhibernate+WCF+WPF. One of the things that is done quite terribly is object graph serialisation, In fact it isn't done at all, currently associations are ignored and we are using DTOs everywhere. As far as I can tell one method to proceed is to predefine which objects and ...

NHibernate not persisting collections

Hi, I have a rather strange error with NHibernate. I am was having error with ISession been shared by across threads and got this resolved by supplying my own ADO.NET connection like: IDbConnection connection = new SqlConnection(ApplicationConfiguration.ConnectionString); connection.Open(); ISession...

Eager loading of lazy loaded entities in nHibernate using ActiveRecord

I'm working on a project that has a rich object model with various sets of aggregate roots. We're using the Castle stack (Monorail through to nHibernate with ActiveRecord). We have marked the aggregate roots as lazy [ActiveRecord(Lazy = true)] and have customized 'eager' routines on our Repository to eager fetch an object graph. We us...

How do I limit the result set being pulled back by NHibernate's GetByCriteria?

I have an NHibernate Dao..lets call it MyClassDao for want of a better name. I am writing the following code. MyClassDao myDao = new MyClassDao(); var values = myDao.GetByCriteria(Restrictions.Eq("Status", someStatusValue)); I am using this in a Unit Test to pull back values from the database. However, it is taking over 30 seconds t...

NHibernate efficiency

Having fallen behind in the world of ORM and modern data access, I'm looking to move away from DataSets (shudder) and into a proper mapping framework. I've just about got my head around Linq to SQL, an I'm now looking into NHibernate with the view to using it in our next project. With old school sql and data sets, your sql queries obvi...

using (Fluent) NHibernate with StructureMap (or any IoCC)

Hi, On my quest to learn NHibernate I have reached the next hurdle; how should I go about integrating it with StructureMap? Although code examples are very welcome, I'm more interested in the general procedure. What I was planning on doing was... Use Fluent NHibernate to create my class mappings for use in NHibs Configuration Implem...