nhibernate

Does SQL Server CE support schema update with NHibernate?

SchemaExport seems to work, but SchemaUpdate fails - the SchemaUpdate.Exceptions contains this object: System.NotSupportedException: The method is not supported. in System.Data.Common.DbConnection.GetSchema(String collectionName, String[] restrictionValues) in NHibernate.Dialect.Schema.AbstractDataBaseSchema.GetTables(String catalog, St...

HQLBasedQuery to ProjectionQuery Castle ActiveRecord/NHibernate

Hi, I'm trying to query using Castle and return a strong-typed array or IList for later use in data binding, so from i read a ProjectionQuery would be my best choice, but how would i transform this to a projection query: HqlBasedQuery hql = new HqlBasedQuery(typeof(TrackingRule), Query...

Map table inheritance as a one-to-one relationship with NHibernate

Hi! I have a database that has a one-to-one relationship modeled between a Person and a Address (that uses person id). However, I cannot find a way to make the map using NHibernate. My table structure is the following: PersonTable PersonId PersonName PersonAge AddressTable PersonId CountryName StreetName StateName And I would l...

NHibernate table per hierarchy mapping issue

We have the following table structure: tbl_A A_ID INT PK Type_ID INT tbl_EA EA_ID INT PK A_ID FK to tbl_A C_ID INT (reference to other table based on Type_ID from tbl_A) tbl_C C_ID INT PK So, we're thinking tbl_A is abstract class, and each type is a subclass, discriminator based on Type_ID. But then we ...

NHibernate Subquery Linq - How to select groups that contain a certain item by id

Short Version This query works in the database but fails with Linq To NHibernate. Why? var items = (from g in db.Find<DataGroupInfo>() where (from d in g.data where d.Id == dataID select d).Count() > 0 select g).ToList(); Detailed Long Version I have two objects mapped by NHibernate Automapper with a Ma...

System.Security.SecurityException

I'm developing a web application with VS2008 and NHibernate and I cannot access my database (MSSQL Server 2005). Here is my stack trace [SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] System.Se...

NHibernate + Mappings + Domain Model = Over-engineering?

Background I really like Fluent NHibernate - it's pretty great. I don't have to write those mundane CRUD-based SQL stored procedures and that's great (not that there's anything wrong with that)! I've gone down this path a bit on an application we're working on. And now I'm sitting with a couple dozen domain objects, each with a reposit...

Nhibernate - how to delete children?

I'm working on a project with NHibernate that classes similar to the following: public class Parent { public IList Children {get;set;} // ... } public class Child { // ... } I've got the Children property set to cascade all / delete orphan. Since I'm using the aggregate pattern and instances of Child class will only ever ...

NHibernate Collection Mapping Help

I have a root object, Policy, that has a compositeKey of PolicyNumber/PolicyDate. The Policy has a one-to-many collection of PolicyDetails which have a composite key of PolicyNumber/PolicyDate/Sequence. Sequence is an assigned value that is set by the application. My Mapping for Policy is below. I'm able to do a get and populate my c...

Does Castle ActiveRecord supports SQL formula?

Does Castle ActiveRecord supports SQL formula as supported by nHibernate? E.g. In nHibernate we can do something like this. <property name="CountOfPosts" formula="(select count(*) from Posts where Posts.Id = Id)"/> Is this supported in Castle Active Record? ...

Property Mapping based on dynamic criteria at runtime

Hi All, I have been sifting through pages on Google looking for the answer to no avail, however I think I am just phrasing the question incorrectly. The scenario is as follows: I have an entity which users are able to either vote for or against. For arguments sake lets call the entity a business. I would like to have a property on my ...

Will NHibernate attempt to save the same object twice in this scenario?

Lets say I have two entities: Stable, and Pony. Stable has an IList<Pony> with a HasMany mapping configured with Cascade.All(). That means that if I do session.Save(myStable), each Pony in the collection will be saved. However, what happens if I do this? Pony myLittlePony = new Pony(Color.Brown); Stable myStable = new Stable(WoodType...

Nested select not working in NHibernate.Linq

I want to load the list of users and their roles, with this query: var q = from u in session.Linq<User>() select new { u.Name, u.Password, Roles = from r in u.Roles select new { r.Code, r.Name } }; But this query is not working. Produce the following ...

property Access strategies in nhibernate

What are the access strategies that I can use in the attribute access of the nhibernate xml? Can someone point me the possible values to be used in it? A nice tutorial would be very appreciated. Thanks ...

NHibernate.Linq, WCF RIA Services, weird error.

Hi all. I have a Silverlight Business Application project set up, with these codes. I have this domain class: public class BaseDomain { public virtual Guid Id { get; set; } public virtual DateTime CreatedOn { get; set; } } public class Sector : BaseDomain { public virtual string Code { get; set; } public virtual string...

Control the way nhibernate does querying

I've experienced a couple of days ago, that a problem with the name of the fields in the final query. It was a bug from a version before the 2.0.GA. To not drag too long on this, it was a problem when the query is too big, and you use SetMaxResults altogether. It got me a though: Would there any way to control how NHibernate is going to ...

NHibernate - When FlushMode is given as Never and if I close the session by session.Close(), will the changes be sent to server?

If I have the FlushMode as Never and if I do a session.Close() will the changes be persisted to the database? Or do we have to explicitly say session.Flush() before session.Close()? Thanks ...

DateTime incorrect when added to SQLite DB through (Fluent)NHibernate

I have a component that i want to store to an SQLite database. public class Comp : Entity { public virtual DateTime TimeStamp { get; set; } public virtual String Name { get; set; } } public class CompMap : ClassMap<Comp> { public CompMap() { Id(x => x.Id); Map(x => x.TimeStamp); Map(x => x.Name);...

NHibernate collection not loading with data, but data is inserted into database.

Hi, Not sure what I am doing incorrectly here with NHibernate. I have two mapping files mapped to two tables. I can insert data through the mapping into the database, but calling the below code returns 0, even though I can see a child row populated in the table with the correct foreign key. Is this a lazy loading issue? Thanks. var res...

Why is my Lucene index getting locked?

I had an issue with my search not return the results I expect. I tried to run Luke on my index, but it said it was locked and I needed to Force Unlock it (I'm not a Jedi/Sith though) I tried to delete the index folder and run my recreate-indicies application but the folder was locked. Using unlocker I've found that there are about 100 ...