nhibernate

Querying entity in NHibernate by average value of subentity

Hi all. I've got an entity Product like this: [Class(0, Name = "Product", Table = "Products")] public class Product { private readonly ISet<ProductPropertyValue> _productPropertyValues; private readonly ISet<ProductImage> _productImages; private readonly ISet<ProductComment> _productComments; private readonly IList<Categ...

What Good Tutorials/Guides Are There For Getting Started with NHibernate?

Hi All, I have finally decided to spend some time looking at using NHibernate for helping TDD my DAL code. I came across this excellent "foundations of programming" eBook from Karl Seguin and he gave some small examples on using NHibernate, and how it improves the testability of your DAL. Can anyone here offer any good resources for a...

Would you use NHibernate for a project with a legacy database, which is partly out of your control?

For me the answer is currently: No, I would use iBatis, because NHibernate is a pain, when the database model and the object model are not in synch. If I don't have full control over the database I end up with a lot of work. Why do I ask? Well, first of all: I never used NHibernate. I just know it from the surface. I have read about th...

How to configure NHibernate to use connection string from <connectionStrings> configuration section

Hi, does anybody know how to configure NHibernate properties file to use a connection string already specified in configuration element? ...

Using a CASE statement in HQL select

Is there any way to do the following in HQL: SELECT case when flag = true then SUM(col1) else SUM(col2) FROM myTable ...

NHibernate Insert is Committing but object is not persisted in table.

When debugging everything appears good. The insert commits and there is no roll back, no exceptions. I sure hope some can help with this. Here is my call: using (ITransaction transaction = _session.BeginTransaction()) { _session.Save(calc); transaction.Commit(); } Real simple mapping: <hibernate...

Cascade delete from collections in multiple entities

I have three entities: Customer, Device and LocationTag. Customers have a list of LocationTags (nothing more than an ID and a Description). They also have a list of Devices. Devices are tagged with a subset of the Customer's LocationTags, so Devices have a List of LocationTags, too (but only of the Customer's). If I delete a Locat...

PostgreSQL full-text search vs. NHibernate.Search via Lucene.Net

I am considering whether to choose NHibernate.Search or PostgreSQL's embedded full-text search support for my current project. We are using, as you have already guessed, PostgreSQL RDBMS with NHibernate ORM on the .NET platform. What experience have you on above mentioned full-text engines? Is there any pitfalls I should be aware of? ...

NHibernate.Search, Lucene index files not created

I have come across an issue with NHibernate.Search, where it all of a sudden stopped working, it cannot create files nor read the index-files at all. NHibernate seems to load it correctly: 2009-01-20 17:37:17,751 [1] DEBUG NHibernate.Impl.SessionFactoryImpl - instantiating session factory with properties: {use_reflection_optimize...

NHibernate - Mapping a String Foreign Key

The legacy database I've inherited contains the following tables: Teams ( TeamId INT PRIMARY KEY, Name VARCHAR(30) ) Players ( PlayerId INT PRIMARY KEY, Team VARCHAR(30) ) The foreign key in the players table refers to the team name, rather than teamId. I've attempted to map from Team to Players using a bag: <bag name="Players...

How to create composite UNIQUE constraint in FluentNHibernate?

I know that I can Map(x => x.GroupName).WithUniqueConstraint() for a single property. But how do create a composite unique constraint in fluent nHibernate (where the unique constraint operates on the combination of two columns)? ...

Is it OK to call virtual properties from the constructor of a NHibernate entity?

take a look at this example code: public class Comment { private Comment() { } public Comment(string text, DateTime creationDate, string authorEmail) { Text = text; CreationDate = creationDate; AuthorEmail = authorEmail; } public virtual string Text { get; private set; }...

How well does ASP.NET Dynamic Data work with Nhibernate today?

I know there are a few people working on getting Nhibernate to support ASP.NET Dynamic Data. Anyone got real life experience of using it? ...

Is there a way to map a one-to-one with a where clause?

Please excuse my ignorance on the topic, as I am relatively new to Hibernate / NHibernate, but I have encountered a mapping I can't figure out: This is what my database table looks like: <bincontents> <id>5873715</id> <title>Video Title</title> <sortorder>0</sortorder> <itemid>23079</itemid> <itemtype>VIDEO</itemtype> <...

How do I map a one-to-one association with NHibernate using foreign key generator?

So far the association works fine (the User class loads the appropriate UserRoles instance when present), but when creating a new User and setting its Roles property to a new instance of UserRoles, the UserRoles object is not saved. Here is my abridged User.hbm.xml: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:...

What are the differences and pros and cons of these ORM tools/technologies?

Duplicate: http://stackoverflow.com/questions/66156/whose-data-access-layer-do-you-use-for-net http://stackoverflow.com/questions/380620/what-object-mapper-solution-would-you-recommend-for-net-closed http://stackoverflow.com/questions/217655/using-entity-framework-entities-as-business-objects http://stackoverflow.com/questions/146087/...

Deleting an object that references itself with NHibernate 2.0.1.GA

I've recently upgraded from NHibernate 1.2 to NHibernate 2.0.1.GA and an issue has occurred attempting to delete an object that references itself. The mapping file: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" ..> <class name="Account" table="Account" polymorphism="explicit"> <id name="ID" column="ID"> <g...

Trouble using nHibernate 2.0's Session.Get<T> on a class with a composite-id

I'm having trouble with something that (I think) should be simple, but can't find any clear info. In the scenario where I have three tables, describing a domain where a person can have more than one job: Person - has PersonId, Name Job - has JobId, JobName PersonJob - has PersonId, JobId, YearsOfEmployment Note: In my object mode...

NHibernate and a REST Service Layer

If ADO.NET Data Services (Astoria) adds a REST layer on top of Microsoft's ADO.NET Entity Framework, is there an equivalent project that adds a REST layer on top of NHibernate? ...

How to construct this NHibernate query

I have a one-to-many relationship. I would like to construct this query: Give me all the parents that have only one child and for this child child.Type=X Since I 'm learning, please show me the query with the Criteria API and with HQL. Thanks. And btw, is there any automatic way to know what HQL is identical to a criteria expression ?...