nhibernate

Fluent NHibernate mapping IList<Point> as value to single column

I have this class: public class MyEntity { public virtual int Id { get; set; } public virtual IList<Point> Vectors { get; set; } } How can I map the Vectors in Fluent NHibernate to a single column (as value)? I was thinking of this: public class Vectors : ISerializable { public IList<Point> Vectors { get; set; } /* H...

What problem does NHibernate solve?

I've seen some jobs that require nhibernate knowledge, as well as numerous questions on stack. I found another question that pointed me to Summer Of NHibernate and I am watching the videos now. However it has no introduction explaining why NHibernate was created and what problem is solves. By looking on wikipedia, I can see vaguely what ...

NHibernate: How do I combine an IQuery with an ICriteria?

I want fetch a list that uses both IQuery and ICriterias.. Is it possible? How do I do this? ...

How to delete a post in Nhibernate?

I try to delete a post in NHibernate but nothing happens. Updating, selecting and inserting new items works fine but when I try to delete nothing happens. IQuery query = session.CreateQuery("from Color where name like '%" + TextBox2.Text.Trim() + "%'"); Color color = query.List<Color>()[0]; session.Delete(color); Ed...

NHibernate Left Outer Join

I'm looking to create a Left outer join Nhibernate query with multiple on statements akin to this: SELECT * FROM [Database].[dbo].[Posts] p LEFT JOIN [Database].[dbo].[PostInteractions] i ON p.PostId = i.PostID_TargetPost And i.UserID_ActingUser = 202 I've been fooling around with the critera and aliases, but I haven't had a...

sql server datetime

hey i have the following query: select * from table where table.DateUpdated >='2010-05-03 08:31:13:000' all the rows in the table being queried have the following DateUpdated: 2010-05-03 08:04:50.000 it returns all of the rows in the table - even though it should return none. I am pretty sure this is because of some crappy date/t...

Should we denormalize database to improve performance?

We have a requirement to store 500 measurements per second, coming from several devices. Each measurement consists of a timestamp, a quantity type, and several vector values. Right now there is 8 vector values per measurement, and we may consider this number to be constant for needs of our prototype project. We are using HNibernate. Test...

How passa parameter to IN Operator in NHibernate?

HI, I'm Trying, pass a long array for a named query (native sql) for to use in a IN STATEMENT: Like this: (...) WHERE Identificator IN (:pIdes) I tried pass my ides as long[]: ctx.GetNamedQuery("NamedQueryName") .SetParameter<long[]>("pIdes", Identificators) ...

nHibernate mapping for entity to multiple different parent entities (eg Addres -> Firm, Addres -> Client)

Can someone help me with the best way to map the following situation in fluent nHibernate? The Address class is used in both Client and Company. How can I store it most efficient in SQL? And what should the mapping look like? I've thought about multiple options, but I'm not experienced enough with nHibernate for these situations: use 1...

Extending fluent nhibernate mappings in another assembly

Hi, I'm using NHibernate with my ASP.Net MVC application. I'm writing some extensions (plugins) for my application. And I'm loading those plugin dynamically (from different assemblies). In my base application I have many entities and mappings defined (User, Group, etc...) I need to create new entities in my extensions, so i.e. I'm crea...

NHibernate Custom HQL for loading

The following is from the NHibernate documentation: 15.4. Custom SQL for loading You may also declare your own SQL (or HQL) queries for entity loading: <sql-query name="person"> <return alias="pers" class="Person" lock-mode="upgrade"/> SELECT NAME AS {pers.Name}, ID AS {pers.Id} FROM PERSON WHERE ID=? FOR UPDATE </s...

NHibernate - get List<long> representing primary keys?

I have a situation where I definitely don't want to get the whole domain object. Basically, the entity has a primary key of long (.NET)/bigint(sql server 2005). I simply need to pass the primary key to an external system which will access the database directly - and since the list of ids could be large, I don't want to rehydrate the ent...

Can you point me to current examples using NHibernate in an ASP.NET MVC2 app?

Can anyone point me to any self-contained, complete, current reference materials/projects using NHibernate in an ASP.NET MVC2 application? I have looked at Sharp Architecture, but I am not sure I need the complexity in that project. I certainly don't know enough about it to know if it is over-engineered for my purposes. I would like to...

NHibernate set : Should I override Equals and GetHashCode ?

I am new to NHibernate. I am using <set ... > mapping for some many-to-one and many-to-many associations. These are exposed as properties of type ICollection<T>, in practice implemented by HashSet<T>. My question is, should I override Equals and GetHashCode for the related types, so they match the database identity of the types (in pra...

How do I change a child's parent in NHibernate when cascade is delete-all-orphan?

I have two entities in a bi-directional one-to-many relationship: public class Storage { public IList<Box> Boxes { get; set; } } public class Box { public Storage CurrentStorage { get; set; } } And the mapping: <class name="Storage"> <bag name="Boxes" cascade="all-delete-orphan" inverse="true"> <key column="Stora...

Generating nHibernate cfg file from Configuration instance

Is there any way for me to generate an nHibernate configuration file from a Configuration instance (that has been already configured by some external code?). I'm looking for an easy way to mimic this external code with a static XML file? (I guess similar to the "ExportTo" method that Fluent nHibernate has for fluent mappings - but actin...

IQuery NHibernate - do I have to Encrypt a parameter that is an encrypted IUserType?

Situation: suppose I have a column on an entity which is encrypted in the database using IUserType: public class EncryptedStringUserType : IUserType { public object NullSafeGet(IDataReader rs, string[] names, object owner) { object r = rs[names[0]]; if (r == DBNull.Value) return null; return...

NHibernate not finding named query result sets in 2nd level cache

I have a simple unit test where I execute the same NHibernate named query 2 times (different session each time) with the identical parameter. It's a simple int parameter, and since my query is a named query I assume these 2 calls are identical and the results should be cached. In fact, I can see in my log that the results ARE being cac...

Dynamic filling WrapPanel buttons from DB, setting the event handlers

I have a table: I'm using NHibernate. The class of entity: public class PurchasedItem { public virtual int Id { get; set; } public virtual Product Product { get; set; } public virtual int SortSale { get; set; } } I want to get all the records table PurchasedItems (my method returns an IList ). Records are sorted in desc...

In NHibernate (Fluent), How do you map a property on referenced object into parent object?

I want to map the Name column from the Child table into the Parent object. How do you do this (using Fluent NHibernate)? public class Parent { public int Key { get; set; } public string ChildName { get; set; } } Tables +--------------+ +------------------+ | Parent | | Child | +--------------+...