nhibernate

NHibernate and Spring.NET Combination really helpful in the enterprise level application!

What are the opinions of the software developers who have used Spring.NET and NHibernate in their projects? In couple of our projects in the company where I work, we have used these third party tools very extensively and we have gained tremendous productivity. A little caveat is that it is a little challenging for junior .Net Developer t...

Hibernate inner join mapping - string where id.

Hi, I'd like to map the following sql in NHibernate. Will I need to make a separate entity object i.e RoomTypeVO mapped to tb_tags to do this? Any help much appreciated. SELECT dbo.tb_rooms.id, dbo.tb_rooms.name, dbo.tb_tags.name AS 'roomType' FROM dbo.tb_rooms INNER JOIN dbo.tb_tags ON (dbo.tb_rooms.typeID = dbo.tb_tags.id)...

Should I check for DB constraints in code or should I catch exceptions thrown by DB

Hi, I have an application that saves data into a table called Jobs. The Jobs table has a column called Name which has a UNIQUE constraint. The Name column is not PRIMARY KEY. I wonder if I should check for duplicate entries myself before I try to save/update a new entry or if it's better to wait for an exception thrown by the data acces...

Is it possible to add many-to-many relationship without initialize collection in NHibernate?

Here is my class: public class User { public int Id { get; set; } public string Name { get; set; } public ISet<User> Friends { get; set; } } Here is my mapping: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Test" assembly="test"> <class name="User" table="Users"> ...

NHibernate2 query is wired when fetch the collection from the proxy. Is this correct behavior?

This is my class: public class User { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IList<UserFriend> Friends { get; protected set; } } public class UserFriend { public virtual int Id { get; set; } public virtual User User { get; set; } public virtual User F...

nhibernate burrow and ASP.Net MVC

I using nhibernate burrow for long conversation. I am preparing to migrate project to ASP.NET MVC, but burrow doesn't support MVC. I trying to change Burrow to work via MVC. But I have no idea what is the best way to do this. I am not sure that HTTP Module is a good way. I think about ActionFilters to initialize conversation. Thanks ...

ASP.Net MVC and N-Tier

Greetings, Apologies in advance that I have not researched this toughly enough to answer the question myself, but I imagine it would take me some time and I would rather know now before I invest more time in learning it. I couldn't find anything in my initial research.. Why use ASP.Net MVC if your already using a multi-tier architectu...

Is it true that NHibernate ISession.save(newTransientEntity) will only return generated Id, but NOT updating the Id property of the entity?

Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA { ... [Id][Generator(class="guid")] public Guid Id {...} [Property] public string Property1 {...} ... } Let say if I add a transient entity to the persistence context with code like this: ... Guid id; using(IS...

NHibernate with string primary key and relationships

I've have just been stumped with this problem for an hour and I annoyingly found the problem eventually. THE CIRCUMSTANCES I have a table which users a string as a primary key, this table has various many to one and many to many relationships all off this primary key. When searching for multiple items from the table all relationships ...

NHibernate query with distance calculation stored proc

I have a stored procedure in my database that calculates the distance between two lat/long pairs. This stored procedure is called "DistanceBetween". I have a SQL statement allows a user to search for all items in the Items table ordered by the distance to a supplied lat/long coordinate. The SQL statement is as follows: SELECT Items.*, d...

ORM and SOA in the .NET world

From my experience the major ORM frameworks for .NET (NHibernate, LinqToSql, Entity Framework) work best when they keep track of loaded objects. This works fine for simple client-server applications, but when using three- or more tier architecture with Web Services in a Service Oriented Archtitecture, this is not possible. Eventually, by...

NHibernate.Search with Lucene.NET without using DB?

Could I use NHibernate.Search only with lucene’s index without database? Because I would like to store all data only in my lucene’s index, but I really like features in NHibernate.Search. ...

How do you filter one to many relationships with fluent-NHibernate?

I have a set of entities where they could possibly be set as deleted using an "IsDeleted" flag in the database. This is fine for the normal set of entities, however when I have a parent with many child entities that may have this flag I would like NHibernate to be able to automatically handle selecting the child entities that have "IsD...

getting proxies of the correct type in nhibernate

I have a problem with uninitialized proxies in nhibernate The Domain Model Let's say I have two parallel class hierarchies: Animal, Dog, Cat and AnimalOwner, DogOwner, CatOwner where Dog and Cat both inherit from Animal and DogOwner and CatOwner both inherit from AnimalOwner. AnimalOwner has a reference of type Animal called OwnedAnima...

Nhibernate foreign key to foreign key collection mapping ?

I have a Staff and e SecuredPage entity and the properties are below Staff id Name LastName Level // SecuredPage.RoleId SecuredPage id PageId RoleId // Staff.Level I want to have a collection of SecuredPage in Staff entity, so it s a one-to-many but i couldnt figure it out how to handle with it in mapping. Staff.hbm.xml <bag name=...

How to map a deeper hierarchy in nhibernate

I have this object graph, I want to map: abstract Account (username, password, ...) abstract Customer (shoppingcart, orders, roles) IndividualCustomer (user data) CorporateCustomer (different user data, company data) Administrator (adminroles) How can this be mapped against one table? (I know how to do this with an entity hierarc...

How do I generate ids with NHibernate and Firebird?

I'm trying to insert some new objects into a firebird database using NHibernate. I get the error "could not get next sequence value[SQL: SQL not available]" Here is the mapping I'm using at present. Note ANML_EVNT is the name of the generator I want to use. <id name="Id" column="ID" type="integer"> <generator class="sequence"> ...

How to Indexing and searching business entities using Lucene.Net?

I would like to know how to use Lucene.NET for indexing and searching my business entities. I see NHibernate.Search has nice features for this issue, but it still needs DB. I don't need DB, I only want to store all data in my Lucene.NET's index. I also see java framework like Compass can do that stuff easily, but it's not .NET library. ...

Full Linq Query Instead of Lambdas with Fluent-NHibernate?

I'm trying to use Fluent-NHibernate's Query method which looks like this: public T[] Query<T>(Expression<System.Func<T, bool>> where) { return _session.Linq<T>().Where(where).ToArray(); } I'm using VB, so to send it a lambda expression I can call it with a line like this: Dim products = flRepos.Query(Of Pr...

Applying the Hibernate filter attribute to a Bag with a many-to-many relationship

Consider the following Hibernate mapping file: <hibernate-mapping ...> <class name="ContentPackage" table="contentPackages"> <id name="Id" column="id" type="int"><generator class="native" /></id> ... <bag name="Clips" table="contentAudVidLinks"> <key column="fk_contentPackageId"></key> <many-to-many class="Clip" ...