nhibernate

Fluent NHibernate get Id of saved object

I'm using Fluent NHibernate in an Asp.net MVC application. I have it set up to start a session and transaction on every request, and commit the transaction at the request end. However, what I want to do is save an object (in this case, a new "Company") and then redirect to that new Company's detail page. How do I get the Id of the new co...

Hibernate many-to-many delete.

Hello, I have many-to-many relationship in NHibernate between two classes Actor and Movie. public ActionResult removeMovieFromActor(int MovieId, int ActorId) { ViewData["SectionTitle"] = "Usunięcie filmu"; ActorsRepository ar = new ActorsRepository(); Actor act = ar.getActor(ActorId); //what to ...

in NHibernate, map 4 similar columns to list<string>

In my legacy database, I've got a table [Templates] with four columns for the "special instructions" on a shipment: .....|Spx_1|Spx_2|Spx_3|Spx_4|.... .....| | | | |..... I want to map this to a List in my class: public class Template { .. public virtual List<string> SpecialInstructions { get; ...

NHibernate: Join on multiple non key fields with property-ref

I have the following two tables in a legacy database Group --------- Id (PK) Code (char(4)) Year (int) Name nvarchar(100) Person ---------- Id (PK) Code (char(4)) Year (int) GroupCode (char(4)) And I want a class for Person that looks something like this class Person { public virtual int Id { get; set; } pub...

Fluent NHibernate Many-to-One Join on a Substring

I'm trying to map 2 tables together in Fluent Nhibernate, but the only way to join them is based on using the LEFT function on one of the columns. So a SQL join would look like this: select * from TableA INNER JOIN TableB ON LEFT(TableA.ColA, 12) = TableB.ColB Is there any way to map this in NHibernate? ...

Can't figure out what the other side of the many-to-many property 'Users' should be.

My Domain auto mapping was working but now as I updated my NHibernate stack I'm getting mapping exception when Session Factory is building the Configuration: "Can't figure out what the other side of the many-to-many property 'Users' should be." The exception is thrown on a many to many map The whole stack trace is this o...

Is it possible to use NHibernate for retrieving data from SP which returns multiple selects?

My stored procedure: CREATE PROCEDURE spSomeStoredProcedure AS BEGIN SELECT CategoryName FROM Categories ORDER BY CategoryName SELECT Top 10 CompanyName FROM Customers ORDER BY CompanyName END GO I tried to use ISQLQuery, but List() method returns data only from the first SELECT ...

TDD with NHibernate

Hello everyone I want to start a test driven development with ASP.Net 3.5 (C#), NHibernate with Oracle and NUnit. Can any body refer me any tutorial about NHibernate with NUnit for beginning. Any book reference will also be appreciated. N.B. I have seen the summer of Nhibernate video series, but it works for SQL server only not oracle...

Questions about caching in high-traffic website.

Suppose we are building an E-commerce site that allows consumers to search for products by typing in keywords. Say there are at most 200,000 products, and there are millions of consumers using the system. Let’s say the product table is updated fairly frequently. Since the number of products is not that high and we can probably store the ...

NHibernate: Applying Filter to Joined Subcass

I have the following mapping: <class where="IsDeleted = 0 or IsDeleted is null" name="File" table="tblFiles"> <id name="Id"> <column name="oid" /> <generator class="sequence"> <param name="sequence">tblFiles_SEQ_OID</param> </generator> </id> <property name="IsDeleted" type="System.Boolean"> <column name="IsD...

NHibernate getting collection within another collection during query

Suppose I have the following class structure: public class State { public int Id { get; set; } public DateTime StatehoodDate { get; set; } public IList<City> CityList { get; set; } } public class City { public int Id { get; set; } public string CityName { get; set; } } Tied to the following tables in NHibernate: CR...

Getting error while starting the windows service

WARN NHibernate.Util.ADOExceptionReporter - System.Data.SqlClient.SqlException: Invalid object name 'X'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Ru...

Concurrency issues

Hi, Here's my situation (SQL Server): I have a web application that utilizes nHibernate for data access, and another 3 desktop applications. All access the same database, and are likely to utilize the same tables at any one time. Now, with the help of NH I'm batching selects in order to load an aggregate with all of its hierarchy - so...

Can I write this query using the criteria API or am I stuck with HQL?

hi all. I have the following query which I would like to write using the criteria api of NH. select status, count(1) from (select distinct Status, post_id from post_statistics) tbl group by status each post_id can exist multiple times in post_statistics e.g. id post_id status 1 1 open 1 1 edit 1 1 open 1 2 ...

lazy-loading and Eagerly loading in Nhibernate

Hello All I am using Nhibernate but still i am confused about (lazy-loading and Eagerly loading) these two topics due to poor understanding of Nhibernate. Please define me lazy-loading and Eagerly loading in simple words. Also why we use castle.Dynamic Proxy ? ...

nhibernate mapping, join without primary and foreign keys

I have these legacy tables which i’m accessing by nhibernate, basic one entity access is fine but i would really need to get joins working. Ideally i would have primary and foreign key to define the joins but as these are legacy tables i only have composite ids that are the indexes for the tables, indexes these have been used for perfor...

Use Component as IDictionary index in AsMap in Fluent Nhibernate

I currently have the following property on an object: private IDictionary<ExampleKey,ExampleObject> example; where ExampleKey is public class ExampleKey { public long KeyField1{ get; set;} public long KeyField2{ get; set;} } This maps with hbm with the following syntax: <map name="example" inverse="true" cascade="all-dele...

Match nHibernate expressions to nested tables?

Hi, Stupid nHibernate noob question, but I can't find the answer anywhere ... I have a "product" class successfully mapped to a product table, and an "sku" class. Sku is a child object of "product" and the two tables in the DB are related by primary key. So far all the basic nHibernate stuff works - I can run CRUD opeations against th...

NHibernate mapping

Hello, I have question :-) How to map this class [Serializable] public class AgentSourceCounter { private int agentId; private IDictionary<int, int> sourceCounters; protected AgentSourceCounter() { } public AgentSourceCounter(int agentId, Dictionary<int, int> sourceCounters) { this.agentId = agentI...

NHibernate Property-ref linked property always lazy loads

I have a property in one of my models that is linked to a non-key field using property-ref. It always lazy loads even though explicitly set to not do so. I have other properties in the same class that reference other model objects using the normal method (on their key fields) and these take note of setting lazy load to false absolutely...