nhibernate

Grouping list of objects where each object is 2 elements array

南笙酒味 提交于 2021-02-11 13:01:53
问题 List<Object[]> values = query.getResultList(); //values = [obj1,obj2,obj3] //obj1 = "1", "01"; //obj2 = "1", "02"; //obj3 = "1:, "03"; Map<String, List<String>> resultMap = values.stream().collect(Collectors.groupingBy(???)); I need a map grouped as - {"1",["01","02","03"]} I have seen few references but nothing seems to work. what should i put in place of "???" ? if you need anything else , kindly comment. Thanks in advance. ref : Shortcut for adding to List in a HashMap groupingby list of

A storage mechanism has already been configured for this application

匆匆过客 提交于 2021-02-08 13:27:04
问题 I am getting this error whenever my S#arp Architecture attempts to start and this is an problem with SQL Server (for example: SQL Server is not runing), after I start SQL Server and hit refresh, I get this error: A storage mechanism has already been configured for this application 回答1: Try to add this line before calling NHibernateSession.Init() to clear any previous initiation. try{ NHibernateSession.Reset(); } catch { } 回答2: NHibernateSession.Init() or InitStorage() is being called more

Maintaining order of updates across transactions to avoid deadlocks

江枫思渺然 提交于 2021-02-08 08:42:32
问题 Does nhibernate have some way of maintaining order of updates to avoid deadlocks across concurrent transactions? For example if I have two transactions T1 and T2 executing concurrently. Let's say I'm updating 2 rows in a table called order on a field called cancelled. T1 Update order set cancelled = 0 where order_id = 1 Update order set cancelled = 0 where order_id = 2 T2 Update order set cancelled = 0 where order_id = 2 Update order set cancelled = 0 where order_id = 1 Obviously the above

Does nhibernate 5.2.3 support .netcore 2.1?

廉价感情. 提交于 2021-02-07 11:00:49
问题 nhibernate nuget package docs The nhibernate 5.2.3 docs say it supports .netcore 2.0 but Does nhibernate 5.2.3 also support .netcore 2.1? 回答1: Yes, NHibernate 5.1.3 or later support .Net Standard 2.0 , can be used with .net core 2.1 or .net framework 4.6.1 which support .net standard 2.0. please refer to the repo https://github.com/nhibernate/NHibernate.AspNetCore.Identity?files=1 for more information. 来源: https://stackoverflow.com/questions/54533122/does-nhibernate-5-2-3-support-netcore-2-1

Does nhibernate 5.2.3 support .netcore 2.1?

北战南征 提交于 2021-02-07 10:59:34
问题 nhibernate nuget package docs The nhibernate 5.2.3 docs say it supports .netcore 2.0 but Does nhibernate 5.2.3 also support .netcore 2.1? 回答1: Yes, NHibernate 5.1.3 or later support .Net Standard 2.0 , can be used with .net core 2.1 or .net framework 4.6.1 which support .net standard 2.0. please refer to the repo https://github.com/nhibernate/NHibernate.AspNetCore.Identity?files=1 for more information. 来源: https://stackoverflow.com/questions/54533122/does-nhibernate-5-2-3-support-netcore-2-1

Fluent NHibernate DateTime UTC

一笑奈何 提交于 2021-02-07 09:45:48
问题 I would like to create a fluent nhibernate mapping to map a DateTime field in a following way: On save - Save the UTC value On read - Adjust to local time zone value What is the best way to achieve this mapping? 回答1: Personally, I would store the date in the object in UTC, then convert within the object when reading/writing. You can then reference the backing field your property uses in the mapping (it's not quite as "fluent" to do it this way but you can use FluentNH to map this). If the UTC

How to auto generate IDs in NHibernate

混江龙づ霸主 提交于 2021-02-07 03:33:05
问题 How can I make NHibernate autogenerate unique IDs for a table? The IDs can be any long values, as long as each one is only used once. My current mapping looks like this: <id name="Id"> <generator class="increment"/> </id> This creates increasing IDs starting at 1, but it resets to 1 at each application startup. So the after each restart, the first element that is stored gets the Id 1 and the previous Id 1 element is deleted (not what I want). Edit: The reason for this is that I used

How to auto generate IDs in NHibernate

青春壹個敷衍的年華 提交于 2021-02-07 03:31:27
问题 How can I make NHibernate autogenerate unique IDs for a table? The IDs can be any long values, as long as each one is only used once. My current mapping looks like this: <id name="Id"> <generator class="increment"/> </id> This creates increasing IDs starting at 1, but it resets to 1 at each application startup. So the after each restart, the first element that is stored gets the Id 1 and the previous Id 1 element is deleted (not what I want). Edit: The reason for this is that I used

Implementing a custom QueryProvider with in-memory query

别等时光非礼了梦想. 提交于 2021-02-07 02:00:41
问题 I'm trying to create a wrapper around QueryableBase and INhQueryProvider that would receive a collection in the constructor and query it in-memory instead of going to a database. This is so I can mock the behavior of NHibernate's ToFuture() and properly unit test my classes. The problem is that I'm facing a stack overflow due to infinite recursion and I'm struggling to find the reason. Here's my implementation: public class NHibernateQueryableProxy<T> : QueryableBase<T>, IOrderedQueryable<T>

手工搭建基于ABP的框架

末鹿安然 提交于 2021-02-03 07:08:27
一个业务功能往往不只由一次数据库请求(或者服务调用)实现。为了功能的完整性,我们希望如果该功能执行一半时出错,则撤销前面已执行的改动。在数据库层面上,事务管理实现了这种完整性需求。在ABP中,一个完整的业务功能称为一个工作单元(Unit of Work,简称UoW)。工作单元代表一种完整的、原子性的操作。即一个工作单元包含的步骤要么全部被执行,要么都不被执行。如果执行一半时出现异常,则必须讲已执行的步骤还原。通常我们将事务管理实现在工作单元中。下面我们从ABP源码入手研究如何使用工作单元。 ABP工作单元(UoW)的工作原理 ABP默认将工作单元应用在Repositories、 Application Services、MVC控制器和Web API控制器等组件。也就是说,这些组件的每个方法都是一个工作单元。ABP文档对工作单元的原理讲得不是很详细,所以我们只能通过源码进行研究。这里我们以MVC控制器为例来了解一下ABP工作单元大致的工作原理。源码分析比较枯燥,最好配套ABP源码阅读,或者 跳到后面看粗体字结论 。 ABP在Web模块初始化时注册了过滤器 AbpMvcUowFilter 。 AbpMvcUowFilter 在请求处理前( OnActionExecuting 方法)调用 UnitOfWorkManager.Begin 方法来开始一个工作单元。