nhibernate

Mapping tree structure with Fluent NHibernate

I am having trouble to map a tree structure using Fluent NHibernate, without also having to put in what I believe is a hack. Consider the following classes: Node (abstract, has int Id and GroupNode Parent (if null, the node resides in the root node)) GroupNode (inherits from Node, has IList<GroupNode> Groups and IList<ItemNode> Items)...

Using SetParameterList and the LIKE keyword

I'm using NHibernate and I have a query which I want to run, which involves returning the whole table plus a count and group by. From what I've read online you can't do this with NHibernate Criteria. To get round this, I'm using a named query: SELECT id, COUNT(id) AS myCount FROM foo INNER JOIN bah ON foo.id = bah.fooId...

Storing a field in FluentNHibernate using one type, but accessing through methods as another type

I am creating a message queue in a database. Each queued item stores a ID and a couple of other things. But the key field is IncomingMessage. In the database I am storing a serialized version of the IncomingMessage because it can be one of a number of types (like NewWorkorderMessage or EmployeeStatusChangeMessage). So the field in my Que...

NHibernate bug sql generator

i have class named Group i tried to test configuration: var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof (Group).Assembly); new SchemaExport(cfg).Execute(true, true, false); when i debug this, im getting following sql: create table Group ( ID INT IDENTITY NOT NULL, Name NVARCHAR(255) null, ...

How flexible is subsonic

I currently use nhibernate but a guy at work has recently gotten me interested in subsonic again. I really prefer a Poco, domain-driven style approach to development and worry about the database later. It looks like this is partially supported using simplerepository. My question is, how flexible is subsonic in how it generates your da...

What does GetByCriteria return when no results are found?

I'm using NHibernate to retrieve a list from the database based on some criteria. List<MyType> myList = GetByCriteria(...) Does anyone know whether myList will be null or an empty list of MyType if no results are found that match the criteria? I've been looking through the NHibernate documentation and searching in google but I can't ...

Handling Dates without years. From the DB all the way to the UI.

In the application I am currently writing the specification asks that a number of dates are entered without years. I want to know everyone opinion of the best way of doing this, at all levels. I am almost certain that they should be stored in the DB as normal Date fields, However before they get here, the year should always be set to th...

CreateFilter() for IDictionary<Key, Val>

For class: public class A { public virtual IDictionary<B, int> dict { get; protected set; } //int is 1 or -1 } public class B { public virtual DateTime CreateDate { get; set; } } That is mapped as: <map name="dict" table="TABLE"> <key column="ID_A" /> <index-many-to-many column="ID_B" class="B" /> <element column="FACT...

Deleting unreferenced child records with nhibernate

Hi There I am working on a mvc app using nhibernate as the orm (ncommon framework) I have parent/child entities: Product, Vendor & ProductVendors and a one to many relationship between them with Product having a ProductVendors collection Product.ProductVendors. I currently am retrieving a Product object and eager loading the children...

Cannot .Count() on IQueryable (NHibernate)

Hello, I'm with an irritating problem. It might be something stupid, but I couldn't find out. I'm using Linq to NHibernate, and I would like to count how many items are there in a repository. Here is a very simplified definition of my repository, with the code that matters: public class Repository { private ISession session; /*...

Is there a practical way of migrating from identity columns to hilo keys?

I work with a database that depends heavily on identity columns. However as we have now moved all applications over to NHibernate I wanted to look into using HiLo as seems to be recommended with NHibernate. Are there any strategies to do this, or any common problems to watch out for? ...

Table of Unique Strings with Fluent NHibernate

I have a class Item and a class ItemAttribute, where Item has a property of type ItemAttribute. ItemAttribute only has two properties, a Guid called ID and a string called name. The idea here is that I want to store a table called ItemAttributes that contains a list of unique strings. My question is, if I save an Item that references a...

conditionally creating criteria nhibernate

Say I have a users table and a countries table, something like: tblUsers int UserId int UserCountry tblCountries int CountryId string CountryName and have the mappings etc appropriately organized for each. How would create a query to retrieve all users from a list of countries, if I had something like List EligibleCountries? Someth...

How do I revert all changes in a NHibernate session?

Since the NHibernate ISession tracks changes, I am wondering if I can discard all changes in a session, like this: class Person { public virtual string Name { get; set; } } // Somewhere else... var session = sessionFactory.OpenSession(); person.Name = "John Doe"; using(var tx = session.BeginTransaction) { session.Save(person); ...

ibatis.net or nhibernate on mono

Hi, I need a stable orm or dataccess framework to use with mono 2.4.2.3. Does anyone used ibatis.net (3.0 alpha or older) or nhibernate 2.1 on mono, are they solid enough for production use ? Regards, sirmak ...

Fluent NHibernate: Weird column mapping behaviour

I am having a number of problems trying to map entities using Fluent NHibernate. I have three entities, like this: public class Product { public virtual Guid Id { get; set; } public virtual Category Category { get; set; } public virtual Seller Seller { get; set; } } public class Seller { public virtual Guid Id { get; s...

With NHibernate and Transaction do I rollback on commit failure or does it auto rollback on single commit?

I've built the following Dispose method for my Unit Of Work which essentially wraps the active NH session & transaction (transaction set as variable after opening session as to not be replaced if NH session gets new transaction after error) public void Dispose() { Func<ITransaction,bool> transactionStateOkayFunc = ...

Odd save behaviour with NHibernate and Rhino Repositories

I am experiencing some odd behaviour with NHibernate. I'm retrieving a list of Learners from a repository, updating them as necessary, the odd thing is when I save the first one, the changes made to all the learners are being commited to the database. [Transaction] public void UpdateLearner(Learner learner) { ...

Nhibernate and db notifications

is there any notification support that nhibernate has in its framework that cna be used to register db changes? ...

NHibernate cache query

Hi! Is it any possible to query the NHibernate cache to find whether my object is there or no? Thank you! ...