nhibernate

Automatic sorting

Is it possible to get nhibernate to sort lists on a specific property/column (if no sorting have been specified)? Maybe in the mapping files or in some other way? ...

NHibernate exclusive lock

Hi can any of you tell me how I can achieve the same or atleast mimic the behaviour. What i want to achieve is that there are two independent tasks each having no clue of the others existence and one of the tasks reads from a table and the other deletes and writes into this table. I want the delete and write to occur only when there are...

NHibernate Property Mapping, best practise for type attribute?

I have a little doubt for mapping of property in hbm file. Sometimes I've mapped the string field of my db in this way: <property name="MyPropName" column="MyColumnName" length="20" /> but the same mapping can be wrote in this way: <property name="MyPropName" column="MyColumnName" type="String(20)" /> my question is...what's the b...

How to mapping that tables using NHibernate (Fluent or XML)

Hello guys... Can you help-me with that database : I´m using Fluent NHibernate, but XML helps too... My problem is with ProductPrice table... Thanks Paul ...

Problems filtering entities from an nhibernate mapping with an IInterceptor

I have a set of entities that implement an interface: public interface ILocalised { Culture Culture { get; } } For lots of complicated reasons I need to filter entities which do not have the correct culture after they are returned back from the DB (i.e. I can't use a Filter). My immediate thought was to create an interceptor that ...

NHibernate many-to-many - how to retrieve property from join table and associate it with a child?

I have an existing many-to-many relationship in SQL that is being mapped to my business entities via NHibernate. I want to add a property to the child (Category below) that is only applicable to the relationship between the parent and the child. In SQL, I would add a field to the join table. How do I use NHibernate to pull that value ...

NHibernate Mapping Generator is redundantly defining columns from Oracle

I'm using the latest NMG version 2.0 RC1 to generate Fluent mappings for an Oracle 10g database. Unfortunately it is detecting multiple instances of many of the database columns, so my output includes up to 5 definitions for each column, all with the same name. I am working with hundreds of tables, so I really do not want to go through...

NHibernate saving "middle man" with has many association

We have Product, Category and ProductToCategory classes. A product has many ProductToCategories, a category has many ProductToCategories. Product includes this property public virtual IList<ProductToCategory> Categories { get; set; } ProductToCategory public class ProductToCategory : Entity { public virtual Product Pro...

transfer data between 2 databases

Hello, I have a requirement to transfer data between databases, namely visual foxpro and mysql. Every so often, I recieve a foxpro database that has a subset of some data that I have to report on. Every time I recieve that new database, it will generally have both new data and updates to existing data. I would like to keep all of the ...

IPreInsertEventListener not firing for child objects

I've wired up IPreInsertEventListener and IPreUpdateEventListener to manage audit logging in my app, which is using NHibernate as the ORM layer. The problem I'm having is that the OnPreInsert() event is fired when the object is persisted, but is not fired for each inserted child object as well. In my case, I have a Canine, which has a ...

Query-only properties with Fluent NHibernate

I can't find how Nhibernate feature described in Ayende's blog works with Fluent NHibernate. As far as I understand, I can map pseudo-field which value is a result of any hql query. Is this correct? How this feature can be used with Fluent Nhibernate? I tried google, but unsuccessful. Code samples or links to them would be much apprecia...

Is there a way to enforce a minimum string length with NHibernate?

I have a string property on an entity that I would like to mark as required. For example, public class Product { public virtual string Name { get; set; } } In my mappings, I can declare Name as required (using Fluent NHibernate): mapping.Map(x => x.Name).Required(); However, this only restricts the string from being null. If I ...

using nhibernate ,to delete entity with details cascade-delete-orphan,why do I have to get the entity with all details, in order to delete them too ??

let's say i have the following entities: public class Order { public int OrderID {get;set;}; public int Version {get;set;}; public IList<OrderDetail> Details {get;set;} } public class OrderDetail { public int OrderDetailID {get;set;} /// Some other properties } when i want to delete the entity like this: Order order = ne...

NHibernate: use of IEnumerable as collection type results in error

I have a class which uses an ISet as a collection type as below: public class Client { private ISet<Contact> _contacts = new HashedSet<Contact>(); public virtual ISet<Contact> Contacts { get { return _contacts; } } } I don't want the collection itself to be able to be modified externally. However, if I change the propert...

How do you optimize Castle ActiveRecord calls

How do you optimize ActiveRecord calls in your ASP.NET MVC 2 web applications ? I'm sitting in front of my project and all is fine until I start to fill in data. Like a lot of projects I have a data structure similar to this: A planet has many countries. A country has many states/provinces. A State has many cities. A city has many neig...

Object Relational Mapping Design Patterns

I want to start building better persistence layers using NHibernate and other ORMs. What are the best design patterns or important design considerations for implementing persistence with ORM? ...

Design patterns for dependent calculated properties in a class?

I have a class representing a domain entity that contains many calculated properties. Most of the calculations depend upon other properties that are also calculated. In it's simplest form an example of the class could look something like this. public class AnalysisEntity { public decimal InputA { get; set; } public decimal Inpu...

Reading an entire database with Nhibernate

Hi, If I use HQL I am able to query the entire system with this: session.CreateQuery("from System.Object") But then I just get all objects in a list, are there any way similar to this to also get all collections populated? ...

NHibernate: Same class for joined tables

I have a mapping that work to retrieve all sales order headers and their sales order lines in a IList: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping ...> <class name="salesH" table="SalesHeader" lazy="false"> <id name="No" column="No_" type="string"></id> <property name="OrderDate" column="OrderDate" type="DateTim...

Why is nHibernate not throwing stale state exception on SaveOrUpdate when row version does not match?

Hi, This leads to a StaleStateException exception: var entity = Session.Load(id); Session.Evict(entity); entity.SomePropert = "Something"; entity.Version = Version--; Session.SaveOrUpdate(entity); // Throws Exception This however does not throw an exception. Also no row is updated. var entity = Session.Load(id); entity.SomePropert =...