nhibernate

My Domain objects are not modifiable; can I use NHibernate effectively with them?

I'm attempting to work with a legacy system which already has well-defined domain objects. I would like to use NHibernate as the ORM for some of these objects, but since I cannot modify the objects to allow their methods to be overridden by NHibernate, normal techniques for lazy-loaded objects wont be viable. Are there any alternative a...

WPF IDataErrorInfo and NHibernate Validation - how to trigger a Validate?

Hi, I recently plugged the NHibernate validation into my app, I've decorated the properties of my domain objects with the NHibernate attributes as so ... [NotEmpty, Length(Min = 1, Max = 40)] public string Description { get; set; } I've also implemented IDataErrorInfo on my Domain Object ... public string this[string co...

How to properly use a NHibernate ISession object - Session Is Closed! errors

I'm running into issues with my ISessions in NHibernate. I keep getting "Session Closed!" errors. Can some one please show me the correct pattern including a definiion of the following methods and when to use each: ISession.Close() ISession.Dispose() ISession.Disconnect() Here's my problem. I have a callback setup to fireoff a process...

SQL index on NHibernate list key column?

I have two C# classes, say Container and Item, and a unidirectional association: class Container { [...] public IList<Item> Items {get;set;} } The NHibernate mapping looks like this: <class name="Container"> [...] <list name="Items" cascade="all-delete-orphan"> <key column="ContainerId"/> <index column="Position"/> ...

Why does NHibernate need non-settable members to be virtual?

NHibernate requires not only settable properties of your domain to be virtual but also get-only properties and methods. Does anyone know what the reason for this is? I cannot imagine a possible use. ...

Fluent Nhibernate and quartz

I'm building a asp.net mvc web application. And I'm running quartz in the asp.net context. I'm using fluent nhibernate for my or mappings. I'm building a simple job that goes writes an entry in the database. public void Execute(JobExecutionContext context) { ISession session = DataSourceConfiguration.GetSessionFactory()...

SubSonic vs. Castle ActiveRecord

For an upcoming project C# code needs to be written around a legacy Oracle database. It will be very data centric, because most of the code will deal with data manipulation -- there are almost no business rules. So I decided against a full blown ORM and opted for an Active Record approach. I come across two options: SubSonic and Castle ...

NHibernate: simple delete orphan scenario not working

I'm trying to have a simple one to many relationship/hierarchy using NHibernate. I would like orphans to be deleted automatically but my current attempts to do so all result in an ObjectDeletedException. I'm wondering if someone can tell me what I'm doing incorrectly. EDIT: I should have specified that I'm loading a root Foo, then remo...

Castle ActiveRecord Mapping problem

As the result of yesterday's discussion , I have decided to use Castle ActiveRecord for my ORM task. I have added attributes to the class according to the starting guide. After fixing some obvious errors, I was greeted with this: *Could not find configuration for CLASS_XXX or its root type Castle.ActiveRecord.ActiveRecordBase this is us...

NHibernate unique constraints

I've run into some trouble with unique constraints in NHibernate. I have a User entity that is mapped with a unique constraint for the Username property. What I want to do is to be able to check if a particular username exists before a new user is added and also before an existing user updates it's username. The first scenario (adding ...

(N)Hibernate find content from schema: Object <- AttributeValue -> Attribute

We have a common db schema of: Object <- AttributeValue -> Attribute lets say we talk about houses. The house can have lots and lots of attributes (door shape, roof color etc.). The number of attributes for concrete house is not known. Straight forward mapping to objects is used: House - contains collection of HouseAttributeValue ...

Multi Table mapped on one class in NHibernate

Hi, we use an external Database where we cant edit table designs only add own tables to extend the core tables. So I need map two tables on one class, i try this: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DaVinci" namespace="DaVinci.Domain"> <...

Perform mutable updates in LINQ query?

I have a LINQ query where I want to return modified objects. If I were in an immutable Functional mood, I might do something copy-construtor-like, like this: from widget in widgets select new widget { legs = widget.legs + 1, arms = widget.arms } Sadly, I'm doing this on a mutable NHibernate entity object and I have to modify the origi...

NHibernate - QBE and EnableLike()

Hi, I have a problem using QBE with NHibernate. Here's a sample code: Person person = new Person(); person.FirstName = "e"; using (ISession session = SessionFactory.CreateSession()) { Example example = Example.Create(person).ExcludeProperty("DateOfBirth").EnableLike().IgnoreCase(); IList<Person> people = session.CreateCriteria<P...

NHibernate joined-subclass error - Object does not match target type

I'm getting an error when I try to add a object to the database using joined-subclass with NHibernate. Here's my code: Pessoa.cs namespace CarvalhoRodrigues.Domain.Cadastro { public class Pessoa { public Pessoa() { this.Endereco = new List<Endereco>(); } public virtual long Id { get;...

Reuse component in projection (NHibernate)

Is it possible to reuse a component mapping in a projection? Here is the mapping for the Vendor entity: <class name="Vendor" table="vendor"> ... <property name="Name" column="Name" /> <component name="Address" class="MyProject.Address, MyAssembly" > <property name="Street" column="street" /> <property na...

NHibernate: Make sure that the foreign key is not null

Is there anyway to make sure that when I export schema in NHibernate, I can make sure some of the columns must not be null? For example, in the below case, the column Doc_ID in ReuploadTable must not be null: <class name="Test.Generated.BusinessObjects.DocumentStore, DAL" table="document_store" lazy="true"> <id name="Id" column="Id">...

wont save to database with guid as id- fluent-nhiberate

hi. i got problems with saving when i use Guid as identifier. can anybody se what i am missing here? i create my own guid so i dont want it to be generated by database. NOTE: i have tried the guid.combo in mapping to without any success. public class Order { public virtual Guid Id { get; set; } public virtual ICollection<Orde...

NHibernate conversation with ASP.NET+IoC+PostSharp?

Does anybody know a good example of how an NHibernate conversation can be used in a Web context (ASP.NET or ASP.NET MVC) using an IoC container and AOP? Personally, I use Castle/Windsor and PostSharp, but I will appreciate everything that points me to the right direction. ...

NHibernate, WCF & SqlServerCE - Exception thrown loading driver

Background I have a BLL DLL that uses NHibernate. I share the same BLL between a client application and the WCF service (even though the client runs on another machine). I can successfully use either SqlServerCe or SqlServer driver with the BLL with the client application but can only use the SqlServer driver for the WCF. If I change...