Questions tagged [nhibernate]

10517 questions
1

votes
0

answer
57

Views

NHibernate JoinAlias avoid select of nested items

I have a parent children relation, and I need to filter parent and children i some way, here a snippet example: Child childAlias = null; session.QueryOver() .JoinAlias(i => i.Children, () => childAlias) .Where(() => childAlias.Name == 'Child01') .And(u => u.Id == 'a4ccba801f1844b4921e17edb9ffa13f')...
Luca Mazzanti
1

votes
0

answer
61

Views

Nested abstract base classes and table-per-concrete-class in fluent nhibernate

I am having a problem replacing a legacy ORM with fluent nhibernate. I am trying to figure out how to map nested abstract classes with table per concrete class, while using Automap. Compared to the examples I have found, I have two abstract classes in my hierarchy. public abstract class AbstractBase...
fabsulous
1

votes
0

answer
126

Views

NHibernate many-to-one CRUD operations

I'm looking for a an example of CRUD operations for many-to-one NHibernate schema. I've found only basic examples and they didn't help me. I try to insert a new object in the DB and get NHibernate.Exceptions.GenericADOException Code for insert operation: public bool CreateBook(Book book) { try { usi...
firienn
1

votes
0

answer
55

Views

Fluent Nhibernate Mapping Issue/Query Issue

Thanks for the help everyone. I am using Fluent Nhibernate and having some mapping issues. So basically I have two tables....Person and Patient. Person has a PK called Id and Patient has a PK called PersonID which is also an FK to Person.Id. Table - Person PK - Id Table - Patient PK - PersonId (F...
Zach Davis
1

votes
0

answer
38

Views

How to keep updating DataGridView when database is updated

I'm working on a program that uses NHibernate to communicate with a SQL Server, and displays a table in a DataGridView. This is how I initialize my DataSource: private void UpdateDatabaseBindings() { if (InvokeRequired) { InvokeUI(UpdateDatabaseBindings); return; } using (var session = NHibernateH...
Ilan321
1

votes
1

answer
75

Views

Nhibernate sequence with c#.net

I have a conversion project (from oracle to sql server) and using NHibernate to handle database operations. Saving is working when we Save entity by using oracle . here for a column has sequence But same if we do in SQL server it is not working as getting 'null Identifier' . want to remove scope_i...
user455915
1

votes
0

answer
52

Views

Returning ROW_NUMBER() from Nhibernate QueryOver

I've been feverishly trying to figure out how to return the ROW_NUMBER() (not the row count) from a NHibernate QueryOver. This has now become equal parts a learning exercise, so i understand that there are easy alternatives like returning the whole set and iterating through it. But lets stick with...
Juls
1

votes
0

answer
34

Views

NHibernate namedquery vs sqlquery

There are several articles that suggest to use NHibernate named queries instead of native SQL queries. I mean Session.GetNamedQuery() vs Session CreateSQLQuery(). It is said that named queries are parsed in application startup and put in cache for using later, sql-queries are parsed every time they...
DNQ
1

votes
0

answer
80

Views

NHibernate many to one results in Operation is not supported

Hi I'm making a web app on .net core 2 using NHibernate. When I try to add many to one mapping in .xml I get this exception: fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id '0HLEFGR5COP4F', Request id '0HLEFGR5COP4F:00000002': An unhandled exception was thrown by the application. System....
Andrej Paučo
1

votes
1

answer
102

Views

NHibernate .SelectList() with List<string> in C#

I have a database request which looks as follows: var userHasProfessions = xy.GetUserProfessions(); var users = sessionService.GetDefaultSession() .Query() .Where(a => userProfessions.Contains(a.Profession.Id)) .ToList(); It gets all users that the requesting user is allowed to see, depending on his...
1

votes
1

answer
68

Views

NHibernate is unable to resolve classes in a dynamically loaded assembly loaded from a subdirectory

//Formatting is not properly done. Using nopcommerce plugins written in nhibernate and .net core, each plugins contains its own entities directory, but when NHibernate configuration fails var cfg = new Configuration(); cfg.Configure(CommonHelper.MapPath('~/App_Data/db/defauls.config')); // error he...
Joyce K
1

votes
0

answer
11

Views

How can I register two database connections with nhibernate/lightcore?

I have to set up to the existing database(Ms Sql) another one(PostgreSql) with Fluent Nhibernate for my C# Mvc Applicaton. Someone know how can I register the postgreSql database in the LightCoreConfiguration (global.asax)? Global.asax protected void Application_Start() { MvcHandler.DisableMvcRespon...
Alex
1

votes
0

answer
58

Views

Fluent NHibernate disable cache globally

I am using fluent nhibernate. I have problems with the caching so i would like to disable it. How can i disable the cache globally for all queries, without adding session.clear or REFRESH before every query?
Ravid
1

votes
1

answer
147

Views

C# Fluent NHibernate Overview Mapping

I have three classes: public class BaseEntity { public int Id { get; set; } } public class DocumentOverview : BaseEntity { public string Name { get; set; } } public class Document : DocumentOverview { public byte[] Data{ get; set; } } In my application there is a tree and I want to load document nam...
horotab
1

votes
1

answer
39

Views

NHibernate - deleting row is postponed to Commit(), but adding row not.

My problem is that the NHibernate postpones operation of deleting rows, whereas other operations are not postponed, and it causes exceptions. In my database I have User table with unique field: Login. I am using NHibernate 5.1.3, .NET version 4.6.1, C#. Below I paste the fragment of my code that...
Konrad
1

votes
0

answer
296

Views

Fluent NHibernate with ASP.NET core

I am building a web api with Asp.net core and FluentNHibernate however I am getting the following exception: An invalid or incomplete configuration was used while creating a SessionFactory. The inner exception is: Could not load type System.Diagnostics.PerformanceCounter from assembly. I research...
Andra Avram
1

votes
1

answer
62

Views

NHibernate Linq Expression dynamic projection

How can i dynamically change the selected columns in the generated sql query when using a linq expression? Its a new session for each time the query is executed. Even when I set the MapExp as null after first creation an then changing the bool value to false, it still generates the column in the sql...
marjohansson73
1

votes
2

answer
121

Views

NHibernate hasOne lazy load

I have a parent-child relation, with just one child on Sql Server. The child contains fat blob data I won't load. The child is optional and it must depend on the lifecycle of the parent. So the foreign key on the child, point to the parent and is unique. I can use the official example on Hibernate r...
Luca Mazzanti
1

votes
1

answer
38

Views

NHibernate throws an exception 'Data Source cannot be empty'?

I'm a newbie to NHibernate and trying to get my first app working with NHibernate + SQLite - In memory DB. so far, I've done the following, hibernate.cfg.xml NHibernate.Connection.DriverConnectionProvider NHibernate.Driver.SQLite20Driver 'Data Source=:memory:;Version=3;New=True;' NHibernate.Dialect....
SanVEE
1

votes
1

answer
167

Views

NHibernate - Error dehydrating property value - updating entity

I'm having problem when saving an entity with association. Below is my code which gives the error Fluent Class inherited from Fluent Migration public override void Up() //Update your changes to the database { Create.Table('assinatura') .WithColumn('id').AsInt32().Identity().PrimaryKey() .WithColumn...
Paulo Balbino
1

votes
1

answer
279

Views

Best practices with interface projections for JPA Repository in Spring?

I was wondering if anyone can give feedback on a pattern that I am currently playing around with? It involves having an entity implementing a DTO interface that is also used (as a projection) in a JpaRepository interface – for the same entity – to return query results with specific columns. The...
Andy Tang
1

votes
1

answer
22

Views

Fluent NHibernate & Migrator problem with CRUD operations

I have a problem with CRUD operations in three classes My classes: public class A { public virtual int Id { gry; set;} public virtual string Text { gry; set;} public virtual IList Bs { gry; set;} } public class B { public virtual int Id { gry; set;} public virtual string Text { gry; set;}...
WaldemarBetoniasz
1

votes
0

answer
95

Views

Return output parameter from Oracle stored procedure

I have a problem with my stored procedure in Oracle. I need to call my procedure and return value (output parameter). My procedure looks like: create or replace PROCEDURE NumeratorGetNewId ( p_NumeratorId number, p_Save number, Return_Value OUT number) IS v_NewId number; v_CurrentNumerator number;...
Alex Snigirev
1

votes
1

answer
29

Views

Excluding private fields with fluent nhibernate

I am looking to retrofit a database to an existing codebase with as little pain as possible using NHibernate and an sqlite database. I would like to go about this by using the AutoMapper to map the fields that I tag with a [DatabaseField] custom attribute for any object that inherits from a custom D...
AlexBentley
1

votes
0

answer
25

Views

NHibernate Validator mappings xml from database source

I want to use NHibernate Validator with external (XML) mapping configuration, but without embedding these mapping files as resources in a DLL file. I prefer to store these XML files in a database and get them from there myself before configuring the ValidatorEngine. Example mapping XML: It seems tha...
Matthias
1

votes
1

answer
62

Views

NHibernate MappingException: persistent class TodoLog not found

I have two classes Todo and TodoLog that I have created mapping for and some unittests for their respective constructors. When I run these tests I receive the error Could not load type TodoLog. Possible cause no assembly name specified with the innerexception MappingException: persistent class TodoL...
Bunnynut
1

votes
1

answer
50

Views

NHibernate 5.1 ManyToOne - delete orphan not working as expected

I have following entities: public class Person { public int Id {get;set;} public String Name {get;set;} public Passport Passport {get;set;} } public class Passport { public int Id {get;set;} public String PassportNo {get;set;} // ... other properties } and following mapping (for Person): ManyToOne(x...
JohnnyBzz
1

votes
0

answer
28

Views

NHibernate - linq query (IQueryable) select as annonymous type produces large select list

I'm trying to use NHibernate Session.Query from NHibernate.Linq with projection to annonymous type, but when I check for a null of references property, NHibernate adds to select list each column from main table and every join. Linq query: _session.Query() .Select(x => new { Id = x.Id, OwnerId = x.Ow...
Dominik Michalski
1

votes
1

answer
58

Views

Using NHibernate with SAP Advantage Database Server 12

I'm currently trying to make NHibernate work with SAP's Advantage Database Server 12. Unfortunately, there is not much information around this database server in the internet, but in this case, I have to use it to access an existing database. So I tried to set up a simple test project first which ad...
Ad Rian
1

votes
1

answer
89

Views

C# NHibernate: How to do constructor injection into classmapping derived class?

I am new with NHibernate. I somehow not able to find answer for my issue. So let me ask here. How can I dependency inject something into a class like this: /* public abstract class ByCodeAutoClassMapping<T> : ClassMapping<T> where T : EntityBase ... etc */ using App.Data.Persistence.Infrastructure;...
Erhan KALUÇ
1

votes
0

answer
36

Views

NHibernate second level cache collection hydration takes too long

I have enabled query caching and entity caching in NHibernate to store large collections of objects, needed for repetitive operations. I'm using syscache as cache provider. While I have minimized the number of hits to db, the performance benefit is sub-optimal. Loading entities from second level cac...
MFA
1

votes
0

answer
44

Views

NHibernate and persisting large files

I am using NHibernate v4 and .Net 4.6.1 on a 32 bit application (using SQL Server in my dev environment). I need to store large files using Nhibernate (~1GB). I am storing the files in a lazy loaded blob column. My issue is running into Out Of Memory exceptions when NHibernate tries to persist the...
Nick
1

votes
2

answer
64

Views

NHibernate query over projection

I have two entities A and B where A has one-to-many relationship with B. I would like to create an NHibernate query that fetches all A entities with all the B records, where: the A entity is active the fetched B entities are within a date range (I have 2 c# DateTime objects). entity A +----+-------...
LIvanov
1

votes
0

answer
46

Views

NHibernate. Zero date part issue when time field mapping

I have such a field in my table vsArrivalTime time null and property mapped to this field public virtual DateTime? VsArrivalTime { get { return _vsArrivalTime; } set { _vsArrivalTime = value; } } when I set value and tried to save myClass.VsArrivalTime = new DateTime(); SaveAndFlush(myClass); error...
Dima Sukhorukoff
1

votes
1

answer
38

Views

NHibernate - How to log Named Parameterised Query with parameter values?

I have a parameterised named Query like this : Query moveOutQuery = session.createSQLQuery(moveOutQueryStr.toString()) .addEntity(MyClass.class) .setParameter('assignmentStatus', Constants.CHECKED_OUT) I want to see the actual SQL query with parameters filled in. However while debugging I only get t...
Zafar Nasim
1

votes
1

answer
66

Views

NHibernate: How to increment a column value without concurrency issues

I have a database table CaseSymbol with columns: id, Symbol, LastNo It runs over ASP.NET MVC application. Multiple application instances can get the symbol and increment LastNo. CaseSymbol symbol = this.context.CurrentSession.Get(id); symbol.LastNo++; Then it crashes obviously on following line: thi...
user2818842
1

votes
1

answer
28

Views

Could not create the driver from NHibernate.Driver.OracleDataClientDriver Version=4.030319

I have been battling with this for last few days and I am at my wits end! My project have moved to a new development environment coming from Server 2008 to Server 2016. The application uses .Net Framework 4.0, Oracle Client win32_11gR2 and NHibernate 4.030319. Now of course this all works wonderfull...
Andy5
1

votes
1

answer
81

Views

Nhibernate to return Json with list

I have a problem with my C# code. I can't produce my JSON well. I'm using NHIBERNATE to connect and select data from my SQL Server. I want to produce a JSON with a list object inside it. Need your help guys. NHibernate code: var query = (from partners in session.Query() join partnerUsers in session....
Royce
1

votes
1

answer
43

Views

Why NHibernate create a temporary table when I call the Update method on Query?

I just want to update a column table based on a condition. Here my code : this.session.Query() .Where(e => [...]) .Update(c => new { Enabled = true }); This call generates the following SQL : insert into HT_event SELECT evententit0_.Id as Id FROM event evententit0_ WHERE [...] UPDATE event SET Enab...
Sébastien Ollivier
1

votes
0

answer
68

Views

Nhibernate query very slow compared to ADO.NET

I'm new in NHibernate and I have a big problem with this query. With NHibernate query takes 40s to get 8000 records with 12 columns. This is my code: Entity Public Class Comuni Private _ID_Comuni As Integer Private _Nome_Comune As String Private _Provincia As String Private _Nome_Stato As String Pri...
user2863754

View additional questions