nhibernate

NHibernate: Audit logging using Interceptor or Triggers?

Triggers seems like a simple solution for Audit logging. Why should I use Interceptors? Database portability is one con of trigger... what are others? ...

Getting real instance from proxy under Unity Interception with NHibernate

I'm using Unity to resolve types dynamically for a pluggable architecture. I'm also using interception to apply business rule validation via AOP (using ValidationAspects). Finally, I'm using NHibernate as an ORM to persist domain objects. In order for AOP to work, we use the VirtualMethodInterceptor, as interface interception doesn't wo...

NHibenate cascade problem.

Hi I'm having a problem updating child objects in the following scenario. The mappings are as follows: Parent: Calendar <bag name="defaultCategories" inverse="true" lazy="false" cascade="all-delete-orphan"> <key column="parentID" /> <one-to-many class="DefaultCategory"/> </bag> Child: DefaultCatergory <class name="Def...

(Fluent) NHibernate : One entity composed of fields from different tables

Is there a way of writing an NHibernate mapping so that you can have an entity that is composed of fields from different DB tables? For Example is I have a Person and Address table, I want address fields to appear in my person object. I want an entity like this: public class person { public virtual Guid Key{get; set;} public v...

Xml Element with namespace

We are starting to use nhibernate and have setup a Session Manager to create a new SessionFactory. I need to modify some information the 1st time the app starts. I open the config file (not app.config) using an XDocument. <settings> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <reflection-optimizer use="fa...

Has anyone used any .Net code generation frameworks in Mono? (Subsonic, .netTiers, etc..)

Mono appears to have really come a log way since the last time I really used it. I'm interested in doing some ASP.Net development using Mono. I have used .netTiers/CodeSmith at work and really enjoy the speed with which code generation gives you a clean working data access layer. The question is has anybody used any code generation wi...

NHibernate and string primary keys

We have a legacy database that uses strings as primary keys. I want to implement objects on top of that legacy database to better implement some business logic and provide more functionality to the user. I have read in places that using strings for primary keys on tables is bad. I'm wondering why this is? Is it because of the case-se...

NHibernate: Column does not allow nulls. INSERT fails

I have 2 entities Person and Address, Person has one Address. EDIT: The Address already exists, Im just wanting to save the foreign key. When I do this: PersonDTO person = new PersonDTO(); person.Age = "Bob"; person.Address = new AddressDTO {Key = 123}; Save(person); I get this exception: Cannot insert the value NU...

NHibernate mapping after a normalisation

Please help me - I'm new to NHibernate and I cannot seem to find what I'm looking for. I have two tables in a database: Fund and FundBalance. A Fund can have many FundBalances and a FundBalance has only one Fund. In C#, there is only the FundBalance class. Columns from the Fund table joined with columns from the FundBalance table need ...

Is it possible to set a default value on a property with NHibernate

I'm using Fluent NHibernate for my mappings and the SchemaExport class to the database schema. Is it possible with NHibernate to set a default value for a property/column in the generated database schema? ...

Nullable DateTime in NHibernate 2.0.1

Two issues that will likely be immediately obvious, but I've spent too long already tracking them down: I've set up an AuditInterceptor in order to do automatic auditing on entities that implement my IAuditable interface which is used as follows: public class AuditInterceptor : EmptyInterceptor { public override bool OnSave(object...

NHibernate 2.* mapping files: how to define nullable DateTime type (DateTime?)?

I know one of the breaking changes with NHibernate 2.* is that the NHibernate.Nullables are no longer supported. Therefore, what do you use in your mapping file to map the nullable DateTime? type? For i.e.: Understandably doesn't work: <property name="CreateDate" column="CreateDate" type="DateTime?" not-null="false" /> And no longer ...

Are there any statistics on ORM usage / popularity?

I'm looking for some statistics on the usage/popularity/availability/etc of object relational mapping frameworks (ORMs). An example might be how the number of downloads of a specific ORM has changed over time. Does anyone know of any such statistics? Edit: A little clarification: The reason I want the statistics is to be able to back ...

nHibernate inheritance problem when saving childs

Hello. I'm having a problem: I have User: [Class(Table = "Users", Name = "User")] public class User { [Id(0, Column = "UserId", Type = "Guid", Name = "Id")] [Generator(1, Class = "assigned")] public Guid Id { get; set; } [Property(Name = "Password", Column = "Password", Type = "String")] public string Password { get...

Is NHibernate suitable for an SPC application?

I hear a lot about NHibernate lately (mostly good things) and would like to get to know it. At my company we are planning to create a db based application in C#, and I was wondering if NHibernate was suitable for this project. But as I have no experience with ORM, I can not assess the risks involved. Background: It will be an applicat...

How can I apply a filter to grandparents in nHibernate?

I have a question about nHibernate and filtering. I am using nHibernate 2.2 but I think this will apply to versions as early as 1.2. I have created a simple example to illustrate the problem. I have three domain objects: Country, State, and City (assume the DB tables match the domain and have the appropriate relations defined. I want to...

Mapping Siblings in NHibernate

I've been trying to build a SiteMapNode styled object with NHibernate mappings. The goal is to mimic the ASP.NET SiteMapNode object so that a custom provider can be built using NHibernate for a dynamic backend. The issue I'm running into is the way the tree nature of a site map. The ASP.NET object has a next and previous sibling obj...

NHibernate One-To-Many with Joined Subclass

Never asked a question here before, I'll try to lay this out as succinctly as possible. I've got a Recipe class, that contains lists of three different types of Ingredient Uses. These classes all inherit from the base, IngredientUse. So the mapping looks like this: <class name="IngredientUse" table="IngredientUses"> <id name=...

ArgumentOutOfRangeException : Index was out of range.

Hi, I'm getting this weird ArgumentOutOfRangeException whenever I use the PersitenceSpecification class for verifying an entity that has a reference to a value object. public class CatalogItem : DomainEntity { internal virtual Manufacturer Manufacturer { get; private set; } internal virtual String Name { get; pr...

Database tables to C# entity classes - generator for FluentNHibernate?

Hi I am planning to use NHibernate for my next project with mapping through FluentNHibernate. I have a database already, so I have to generate C# classes for entities mapped to database tables. What tool would you recommend (if there is any?) for automatic C# class generation for NH from MS SQL database? Thanks for sharing. ...