Questions tagged [nhibernate]
NHibernate is an open source object-relational mapper (ORM) for the .NET framework.
17,465
questions
0
votes
0
answers
25
views
Odd NHibernate Timeout (SQL Server 2014)
Using NHibernate v5.3.11 to connect to a SQL Server 2014 instance, I wrote an IQueryOver utilizing paging, which generates the following query for page 1:
/*
[Parameters]
@p0 = 'FAC' [Type: ...
0
votes
0
answers
17
views
Calling stored procedure on Inherited class in [Fluent] NHibernate without discriminators
I have a working Fluent project with some inherited tables
class Base { int BaseId }
class Derived : Base {}
class Derived2 : Base {}
class BaseMap : ClassMap<Base> { ID BaseId ); }
class ...
-2
votes
0
answers
19
views
Nhibernate : Join 2 tables [closed]
Im new to Nhibernate. I have 2 tables, Book, Prices and the following query:
SELECT P.price
FROM book B INNER JOIN prices P
ON B.Id = P.Id
WHERE B.Title = 'Night walks'
I would like to join two ...
1
vote
0
answers
8
views
Inheritance Mapping Fluent NHibernate results in unnecessary joins
The issue is when selecting directly on the base model the generated SQL performs an left outer select on the subclasses.
Basemodel.
public class Node
{
public virtual int ID {get;set;}
public ...
-1
votes
0
answers
14
views
Nhibernate : Inner join Sql statement to Nhibernate ORM
I have 2 tables
Employee
Id
FirstName
1
chris
2
alex
Salaries
EmployeeId
Salary
1
1000
2
2000
and the following SQL statement that i would like to translate it to Nhibernate syntax
SELECT S....
-1
votes
0
answers
36
views
Can NHibernate long session (pattern) have multiple transactions that update data?
I am looking at the NH documentation. The example in the section - 12.5. Session disconnection - illustrates a long running session. However I wasn't expecting the first transaction to save anything. ...
0
votes
0
answers
11
views
nHibernate Addhours link syntax conversion to HQL for Oracle DB and SQLite
During migration of large database we need to change an old datetime value with local time to date time in UTC format. I did not found any direct functionality to cover Ms SQL, Oracle and SQLite our ...
0
votes
0
answers
10
views
NHibernate many to many return null item in a list
I have a many to many relationship between Item and Booker.
Here is an example of a table :
create table Item (
id int generated by default as identity primary key,
name varchar(200) not null
)...
0
votes
1
answer
18
views
How to run an NHibernate SQL Delete with a final SELECT reporting completion?
Description
For a project I'm working on, I'm creating a purge feature that deletes old data from this system's database.
I've found that, while my SQL works correctly when ran from SQL Studio, it ...
0
votes
1
answer
30
views
One-to-one relationship in NHibernate using composite key
I'm trying to figure out the proper way to model a one-to-one (or one-to-zero) relationship in NHibernate, or indeed to learn categorically whether such a thing can be done.
Currently I have two ...
0
votes
1
answer
29
views
Why NHibernate is not sending extra select query in one-to-many during updating child?
I am quite new to NHibernate and I made simple app for testing NHibernate and Entity Framework performance. I noticed some problem with updating child in one-to-many relationship. During updating ...
-1
votes
0
answers
18
views
NHibernate Compatibility with Oracle 19C Client
I am working on a Dot net WCF application which uses dot net 4.6.1 framework along with Nhibernate 3.3 version. Application uses Oracle 11G for database. Recently it was upgraded to use Oracle 19C ...
1
vote
0
answers
30
views
NHibernate MismatchedTreeNodeException
I have a DB handling app in which I came across a problem while updating many to many relation's objects. I have a table Devices and a table Admittances that are connected with one another with a ...
0
votes
1
answer
20
views
How to map a collection of components as a set in fluent nhibernate
I want to map a collection of components on an entity. The component looks like this:
public class PermissionUserSetting
{
public virtual PermissionType PermissionType { get; set; }
public ...
0
votes
1
answer
25
views
How can I edit the EXISTS clause produced by NHibernate?
How can we override the usage of the HqlExists class for it's usage creating an EXISTS clause in a given NHibernate configuration/dialect?
The driver being used requires that only a single column be ...
1
vote
0
answers
28
views
Asp.Net MVC 4.6 use NHibernate for Oracle connection - System.Data.OracleClient requires Oracle client software version 8.1.7 or greater
We have a project which contains ASP.NET MVC 4.6 and it use NHibernate 4.0.
We have folder that has oracle client files and folders. NHibernate use it for connect Oracle( version 11). In addition ...
0
votes
0
answers
19
views
I'm getting error NHibernate.MappingException could it be a many-to-many relationship error
In .Net Core, I need to establish many-to-many relations and one-to-many relations with NHibernate xml mapping, but when I establish these relations, I get an error. When I searched, I could not find ...
0
votes
1
answer
30
views
How to apply IQueryOver<TRoot> methods to IQueryOver?
I'm wrapping QueryOver with the interface IQueryOver. Thanks UnderlyingCriteria I can access to the criteria.
I'd like to use the IQueryOver methods such as Take, Skip ...
My intention is to have a ...
0
votes
0
answers
32
views
NHibernate JoinAlias is not creating an alias in the generated SQL
Apologies in advance for how long this question is :) I've tried to make it as detailed as possible. I did have a look for similar questions, but nothing really matched
I have some legacy code I'm ...
1
vote
2
answers
102
views
NHibernate: How to insert C# [Guid] into MySQL [BINARY(16) DEFAULT (uuid_to_bin(uuid(),1))] column?
Environment: MySQL Server 8.0, .NET Core 3.1, MySql.Data 8.0.28, NHibernate 5.3.11
I have following table:
CREATE TABLE `Master` (
`Row_Id` char(36) NOT NULL DEFAULT (uuid()),
`Path` varchar(1000) ...
0
votes
1
answer
22
views
How to Join a table with a list NHibernate?
I have a list of objects like this
public class MyList
{
public int recordNo { get; set; }
public bool IsValid { get; set; }
}
var result= (from pool in context.Table....
0
votes
1
answer
17
views
Fluent Nhibernate Many to many with a pk and fk in one table
Hey i have the following mysql tables:
and i have the following maping classes:
public class WalletMap : ClassMap<Wallet>
{
public WalletMap()
{
Id(x => x....
0
votes
2
answers
41
views
Cannot insert the value NULL into on referenced object
I'm trying to add a new object with nHibernate, but for some reason it tries to update a field on a referenced object that hasn't been provided resulting in:
Cannot insert the value NULL into column '...
0
votes
1
answer
64
views
Make custom Restriction NHibernate for QueryOver
I'm stuck in a simple problem, I'd like to add a new custom restriction in NHibernate. I want to write a simple QueryOver with a fulltext index, an example with a Projections is here How to use Full ...
0
votes
0
answers
28
views
Fluent NHibernate: How to map FK keys as properties in .NET Core version
we are using fluent API and I need to know how I can map it correctly so we can use ParentId instead of having to go through Parent entity. Is that possible? I know it can be done using EF Core so I ...
0
votes
0
answers
45
views
How to connect to Aurora using SSL and NHibernate?
It seems I am unable to specify a TLS version or can someone help decipher this error?
I am able to connect from the linux machine using mysql command line and the application is able to execute ...
0
votes
0
answers
25
views
Merge two QueryOvers
If I have two separate QueryOvers; for instance:
var q1 = QueryOver.Of<Customer>(() => customerAlias)
.select(x => x.RegionId);
var q2 = QueryOver.Of<Store>(() => storeAlias)
...
0
votes
0
answers
58
views
SqlException: Operand type clash: time is incompatible with bigint
I'm trying to use NHibernate Session Criteria with TimeSpan comparison and getting this exception.
In other words, I have this:
TimeSpan timeNow = DateTime.Now.TimeOfDay;
...
criteria.Add(...
0
votes
0
answers
19
views
NHIbernate Mapping By Code; Unable to add column prefix like Fluent Nhibernate
I have been searching for a while with no success.
I'm implementing a new solution using NHibernate mapping by code and creating a reusable component like the following:
public class AuditTag
{
...
0
votes
0
answers
11
views
What is the best way to map one-to-one relationhip in NHibernate using NHibernate.Mapping.Attributes
I've been trying to map a one-to-one relationship using attributes in NHibernate and I am not getting anywhere. I would love some assistance in mapping it, also is there a different method of modeling ...
-1
votes
1
answer
28
views
Link the object to hibernate session
Can someone please help me?
I have a hibernate situation where I'm retrieving the object from a view and doing a manual mapping to convert it to an object and then trying to attach that object back to ...
0
votes
3
answers
136
views
Linq filtering a list by a composite key (contains and not contains)
I need an understanding of how to filter a list by a composite key with the conditions "contains" and "does not contain".
I have a list
List<Entity>();
where entity is a ...
0
votes
1
answer
19
views
NHibernate: One-To-One-Relationship not correctly updating
I want to map two types, ConnectionProfile to ConnectionType. In my ConnectionProfile I have:
public virtual ConnectionType ConnectionType { get; set; }
in my ConnectionType I have:
public virtual ...
0
votes
1
answer
51
views
How to customize the SQL Server connection ApplicationName property in Nhibernate for profiling
I am trying to correlate SQL query activity in a SQL Server Studio profile trace with different client processes in a large application that I am new to. The connection ApplicationName column in the ...
0
votes
1
answer
63
views
How to update Entity that have one-to-one relation?
I have entities as follows:
public class Device
{
public long Guid { get; set; }
public List<Computer> Computers { get; set; }
public string ShopName { get; set; }
}
public class ...
0
votes
1
answer
19
views
FluentNhibernate Map ValueObject
I have the following use case:
public class Object {
long Id
...
ISet<Tags> tags
}
public class Tag : IEquatable<Tag> {
string Label;
}
Object is an Aggregate Root and ...
0
votes
1
answer
71
views
Nhibernate PostgreSQL dialect does not use "returning" in INSERT statement
I have PG table, where PK is populated by trigger. In pgAdmin it works well. NH mappings is:
<class name="Dokument" schema="srk" table="`Dokumenty`" lazy="true&...
-1
votes
1
answer
34
views
NHibernate Object References to null in Where clause [closed]
I have an ISession.Queryover code block. In where clause, there is a problem as shown below
var receipts= ISession.QueryOver(() => receipt)
.Where(Restrictions.Le(
Projections....
0
votes
0
answers
13
views
nHibernate QueryCache NHibernate.ObjectNotFoundException: No row with the given identifier exists
I encounter an exception during working with nHiberante hql query with query cache. I will try describe situation:
nHibernate, QueryCache enabled
HQL query with region, and cache set to lets say 2 ...
0
votes
1
answer
35
views
NHibernate 5 Criteria must use equivalent of LINQ .Contains()
We have a NHibernate V5 project were some queries need improvement.
We had one query using ICriteria like this:
var list = session.CreateCriteria(typeof(ClockEntry))
.Add(Restrictions.And(
...
0
votes
1
answer
48
views
Error while adding Left Join to Linq query
I am trying to add a left join to my Linq query as below;
var leftJoin = (from person in ISession.Query<Person>()
join cars in ISession.Query<Cars>()
...
0
votes
1
answer
275
views
could not create the driver from nhibernate.driver.sqlclientdriver, nhibernate, version=5.3.0.0, culture=neutral, publickeytoken=aa95f207798dfdb4
I faced the below error fluentNhibernate in .net 6 project but the same code is working in framework 4.8.
Error: could not create the driver from nhibernate.driver.sqlclientdriver, nhibernate, version=...
0
votes
1
answer
109
views
NHibernate tests with SQLite - no such table error when using async methods
I'm using NHibernate in my ASP.NET 6 app. For the purpose of integration tests, I'm using SQLite in-memory database.
This is how NHibernate configuration for integration tests looks like:
...
-1
votes
1
answer
40
views
Nhibernate: Pull back most derived type in "Table-per-class hierarchy"
I'm working through an issue regarding a couple <subclass> elements in a "Table-per-class hierarchy" setup in an NHibernate config. I'm trying to fetch the "most-derived-type"...
0
votes
1
answer
94
views
How to instruct NHibernate to use 'TOP 1' instead of 'FETCH FIRST 1 ROWS ONLY' syntax?
I am using NHibernate 5.3.3.0 with SQL Server Dialect set to MsSql2012Dialect.
I am able to SELECT single row with following code:
session.QueryOver<ProductsEntity>()
.Where(x => x....
-1
votes
1
answer
64
views
NHibernate PropertyRef fluent mapping
Is there any way to make query over joins on different nullable foreign key?
Release notes: https://github.com/nhibernate/nhibernate-core/blob/5.2.4/releasenotes.txt#L103
A collection mapped with a ...
1
vote
1
answer
84
views
Why NHibernate uses NVARCHAR instead of VARCHAR ignoring column type mapping?
When I run the following code:
List<Dag> result = session.CreateCriteria<Dag>()
.Add(Expression.Eq("Object_id", pObjectId))
.List<Dag>().ToList();
}
...
0
votes
1
answer
37
views
How to add "or" statement in ISession.QueryOver?
I have a question:
Is there a way to add "or" statement in ISession.QueryOver ?
Consider I have these values:
val1 = 0;
val2=0;
and my query:
.Where(Restrictions.Eq(Projections.Property()=&...
0
votes
1
answer
24
views
Select constant/value in icriteria
Based on a parameter I would like to select a constant value into a field using NHibernate ICriteria
The desired sql could be like
SELECT ID, 'ConstantTile' Title FROM Table
The only way I can se ...
1
vote
1
answer
49
views
After upgrade to nHibernate v5.x causing DateTime errors on Oracle DB
We recently migrated from nHibernate v4.x to v5.3.9 and we started to have problems with date time fields. After long analysis I find out that problem caused by DateTime.MaxValue which we using for no ...