nhibernate

How to order a HasMany collection by a child property with Fluent NHibernate mapping

I am using Fluent NHibernate to map the following classes: public abstract class DomainObject { public virtual int Id { get; protected internal set; } } public class Attribute { public virtual string Name { get; set; } } public class AttributeRule { public virtual Attribute Attribute { get; set; } public virtual Statio...

NHibernate class referencing discriminator based subclass

I have a generic class Lookup which contains code/value properties. The table PK is category/code. There are subclasses for each category of lookup, and I've set the discriminator column in the base class and its value in the subclass. See example below (only key pieces shown): public class Lookup { public string Category; public s...

Need help to properly remove duplicates in NHibernate

Here is the problem I am having. I have a database with over 100 records in it. I am paging through the data to get 9 results at a time. When I added a check to see if items are active, it caused the results to start doubling up. A little background: "Product" is the actual product line "ProductSkus" are the actual products that exist i...

Fluent Nhibernate Mapping Single class on two database tables

Hi guys, I am having problems with Mapping. I have two tables in my database as follows: Employee and EmployeeManagers Employee EmployeeId int Name nvarchar EmployeeManagers EmployeeIdFk int ManagerIdFk int So the employee can have 0 or more Managers. A manager itself is also an Employee. I have the following class to represent t...

NHibernate - Is ITransaction.Commit really necessary?

Hi I've just start studying NHibernate 2 days ago, and I'm looking for a CRUD method that I've written based on an tutorial. My insert method is: using (ISession session = Contexto.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Save(noticia); transa...

NHibernate - ISession

Hi About the declaration of ISession. Should we close the Session everytime we use it, or should we keep it open? I'm asking this because in manual of NHibernate (nhforge.org) they recommend us to declare it once in Application_Start for example, but i don't know if we should close it everytime we use. Thanks ...

SqlLite/Fluent NHibernate integration test harness initialization not repeatable after large data session

In one of my main data integration test harnesses I create and use Fluent NHibernate's SingleConnectionSessionSourceForSQLiteInMemoryTesting, to get a fresh session for each test. After each test, I close the connection, session, and session factory, and throw out the nested StructureMap container they came from. This works for almost ...

Setting up nHibernate with SQLite

Does anyone have a step-by-step guide on how to use nHibernate and SQLite? I can't figure out which dll's I need and which goes in the references and which just need to be copied. I would also like to know how to create the actual file for SQLite. This is for a small application running .Net 4.0 - I understand some things have changed s...

NHibernate.NHibernateException: Unable to locate row for retrieval of generated properties: [MyNamespace.Company#<null>]

It looks like all of my mappings are compiling correctly, I'm able to validly get a session from session factory. However, when I try to ISession.SaveOrUpdate(obj); I get this. Can anyone please help point me in the right direction? private Configuration configuration; protected Configuration Configuration { get { config...

How about performance of linq to sql, Entity Framework and NHibernate?

I was learning this ORM because think this is good technology for most projects. But most employers required acquirement of ADO.NET and SQL. This ORM not will use in high-loaded system (like popular web-sites)? In which types of projects this ORM will be useful? Are highly loaded projects using ORM? ...

load an object twice and change one of them, the other one doesnt changed

Father father = BL.GetFatherById(1); Product product = BL.GetByID(123); (father.Products[553] == product) product.delete = true; father.Products[553].delete == false !!?? why is that ? aren't they connected ?? its the same object. ...

NHibernate collections: many-to-many relationships

I've got two models, a Product model and a ShoppingCart model. The ShoppingCart model has a collection of products as a property called Products (List). Here is the mapping for my ShoppingCart model. <class name="MyProject.ShoppingCart, MyProject" table="ShoppingCarts"> <id name="Id" column="Id"> <generator class="native" /> </i...

NHibernate Projection Components

Hello guys im trying to hydrate a DTO using projections in NHibernate this is my code IList<PatientListViewModel> list = y.CreateCriteria<Patient>() .SetProjection(Projections.ProjectionList() ...

Application connection with database persist after sucessfull transaction also.MAX CONNECTION POOL SIZE REACHED

Hi , I am using Spring.Data.NHibernate12 on my database level.my application connection with database is not getting released. Underneath given is Dataconfiguration.xml <?xml version="1.0" encoding="utf-8" ?> <objects xmlns="http://www.springframework.net" xmlns:db="http://www.springframework.net/database"&gt; <object i...

nhibernate - mapping with contraints

Hello everybody, I am having a Problem with my nhibernate-mapping and I can't find a solution by searching on stackoverflow/google/documentation. The database I am using has (amongst others) two tables. One is unit with the following fields: id enduring_id starts ends damage_enduring_id [...] The other one is damage, which has the ...

saveOrUpdate(Object) method of Hibernate

when i use saveOrUpdate(Object) method of Hibernate. How can I know that row is updated or new row added into table??? Return type of method saveOrUpdate(Object) is void, so am not able to find out the result after calling this method. kindly help me. ...

NHibernate support .NET 4.0 framework?

Hi, Did you anyone used NHibernate with .NET 4.0 framework? Thanks SDS ...

Nhibernate.Bytecode.Castle Trust Level on IIS

Trying to deploy the wcf service, depended on nhibernate. And getting the following exception On Reflection activator. [SecurityException: That assembly does not allow partially trusted callers.] System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodH...

Fluent NHibernate: Example of a one-to-many relationship on an abstract class of a table-per-subclass implementation

Hi All, I've been trying for ages to find an example (because I can't get it to work myself) of the correct mapping for a one-to-many relationship on an abstract class of a table-per-subclass implementation, in fluent nHibernate. An example below: I'm looking to map the list of Fines on the Debt abstract base class to the Fine class. ...

XML Document straight to Stored Proc Mapping in NHibernate

Hello. I'm building a mechanism to take XML data from a queue and call stored procs to save the data from the XML document directly to the database. This seems like something that NHibernate could address, but of course most of the information I find discusses going from objects to database instead of another data format (XML, in this ...