nhibernate

NHibernate Left Outer Join SubClass

I have 2 entities products and images. Not all images are product images, and images are a sub class of a file below are my entities. I need to find all of the images that are not associated to a product. I'm new to retrieval of entities and have tried numerous approaches. Any ideas or links would be greatly appreciated. public clas...

Is Nhibernate Vulnerable to SQL Injection?

Just wanted to know if there is a big chance to inject SQL While using nhibernate? ...

Eager loading child and child-of-child collections in NHibernate

I've got a problem with NHibernate trying to load a small hierarchy of data. My domain model looks like: class GrandParent { int ID{get;set;} IList<Parent> Parents {get; set;} } class Parent { IList<Child> Children {get; set;} } class Child { } and I would like to eager load all parents and children for a given GrandPar...

ASP.Net MVC, ORM and "heavy" objects

Hi all, i think this issue is common in web applications with a middle-sized model. Let's say I have a SportCenter class holding a list of BasketballField, when showing reservations or properties of a BasketballField I still want to show few information about the SportCenter it belongs to. I'm using ASP.Net MVC and nHibernate for the da...

NHibernate Mapping for User Roles and Privileges

The Scenario I've been banging my head against the wall trying to figure out the correct mapping for 3 entities: User, Role, and Privilege. In my application, Users can have Privileges, which just give a user additional permissions. Users can also have Roles which are essentially privileges that require additional properties. For inst...

faster way to do this select query

Say Employee has three columns FirstName, LastName and ID. The query should first search for a name in firstname, only if its not found search for last name. so select *from Employee where FirstName = 'test%' or lastname='test'%'. wont' work. The query below will work. select FirstName, LastName, ID from EMPLOYEE WHERE LastName ...

NHibernate HiLo ID generator is performing a round-trip to the database per-row inserted

When I configure my application to use HiLo Id generation, I see one round-trip per row inserted in the database. All the documentation I've read has indicated that I should see far fewer round-trips. My objects are all generally configured (fluently) as such: Id(t=>t.Id).GeneratedBy.HiLo("MyObject_Identity","MaxId","1000"); Addition...

if I use Nhibernate can I Switch between databases and not change the Nhibernate code?

What I want to do is convert my whole application to nhibernate from ADO.NET and test it using different databases. i know nhibernate supports many different databases so can i switch between different databases without changing any of my application or nhibernate code? ...

Is it Possible to Migrate a Database from SQL Server to PostGresQL using Nhibernate?

Basically, I just want to know if its possible to use Nhibernate to migrate between databases? ...

NHibernate: Insert and update dates

Using NHibernate, what is the best way to handle InsertDate (a.k.a CreateDate) and UpdateDate columns? For example: public class Customer { public virtual string Name { get; set; } public virtual DateTime InsertDate { get; set; } public virtual DateTime UpdateDate { get; set; } } There are probably multiple ways that ...

Set Identity Seed to some nomber Using NHibernate SchemaExport

How can I define identity seed (and also increment) in NHibernate mapping. Here is my class <class name="MyClass" table="MyClass"> <id name="Id" type="int" column="ID"> <generator class="native"> </id> ... </class> Is there something like: <class name="MyClass" table="MyClass"> <id name="Id" type="int" column="ID" seed="100...

Does FluentNH's PersistenceSpecification allow XML mappings to be tested?

Is it possible to use Fluent NHibernate's PersistenceSpecification to test NHibernate mappings done via XML? ...

Convert a tree of interconnected object in "table" domain

I have to create a domain for the energy transmission field, so I have Breaker, Transformer, Line, Cubible, Busbar, Source. I'm trying to search for a domain implementation that conform to this specification: Cubicle contains Breaker and Transformer Breaker and Transformer and Source have to be connected each other with Line Cubicle ...

How to map a group entity class from a "group name" column in NHibernate?

I have a table in my database looking roughly like this: create table Foo ( Id int identity not null, Name varchar(100) not null, GroupName varchar(100) not null, constraint PK_Foo primary key (Id) ) Now I want to map this table into two entity classes like this: class Foo ...

Lazy NHibernate Sessions

Hi When I invoke the SessionFactory.OpenSession() method a session is created, which contains a open connection to the database. Sometimes I have the need to open a "lazy" session, meaning : I want a session to be created, but I do not want the connection to be opened yet. Only on the first query, or insert or update statement should t...

Nhibernate save update delete relations

Hi, I have a product that has 1 or more product relations. Entities: Product and ProductRelation So product has a property List(Of ProductRelation) Now I have a checkboxlist where I can select a number of products that I want to assign to this product. When I add a new collection of ProductRelations with the new products, It should ...

NHibernate ITransaction and pure domain model

I'm trying to write my Domain Model as persistence-ignorant as possible. The only thing I'm doing right now is marking every property and method virtual, as NHibernate requires that for lazy-loading. In my domain model assembly I define some repository interfaces: public interface IRepository<TEntity> where TEntity : EntityBase { T...

Flushing with Castle ActiveRecord

i saw that i can use SessionScope and have inserts inside the scope of the SessionScope and do flush at the end of the scope. my question is if i can define in some way that after, let's say, every 10 insertions/saves of objects, that they will automatically be flushed to the db. in other words i want to be able to configure the way i ...

Nhibernate Inheritance baseclass issue

Hi, I have what I think should be a fairly simple mapping issue, but not having any luck figuring out what I'm missing to make it work. I'll just jump into a simple example to get to the point of what I'm trying: //Base user class public class UserBase : Entity { //properties user class should have } // //Concrete User class (in di...

NHibernate, Npgsql, and the inet type

Hello, I'm writing a web application using ASP.net MVC, NPgsql and NHibernate with PostgreSQL as the database (using VB... not my choice). One of the tables has two columns with an inet type. In the mapping file, I tried mapping it as a string. This actually worked fine until I had to update a row. I get an error message: "column "myc...