nhibernate

How can I map to a joined subclass with a different column than the id of parent?

别来无恙 提交于 2020-01-03 09:14:23
问题 I am working with a brownfield database and am trying to configure a subclass map which joins to its subclasses with a column other than that of the specified id. The login table has a primary key column login_sk which I'd like to use as its id. It joins to two tables via a login_cust_id column (to make things more fun the corresponding columns in the adjoining tables are named differently). If I setup login_cust_id as the id of the UserMap it joins to its subclasses as expected. For what I

Getting error “Association references unmapped class” when using interfaces in model

丶灬走出姿态 提交于 2020-01-03 05:43:04
问题 I'm trying to use the automap functionality in fluent to generate a DDL for the following model and program, but somehow I keep getting the error "Association references unmapped class: IRole" when I call the GenerateSchemaCreationScript method in NHibernate. When I replace the type of the ILists with the implementation of the interfaces (User and Role) everything works fine. What am I doing wrong here? How can I make fluent use the implemented versions of IUser and IRole as defined in Unity?

Map partitioned table with partition discriminator column

痞子三分冷 提交于 2020-01-03 05:26:07
问题 I have a legacy Oracle 10g database. This database has a table ITEMDELIVERY with a column DELIVERY_DATE . The table is partitioned by this column. Because of that, the primary key of this table is a compound one involving the columns ITEMDELIVERY_ID and DELIVERY_DATE . There is another table ITEMDELIVERYDETAIL having a FK to ITEMDELIVERY . To be able to benefit from the partitioning and to be able to be partitioned itself, this table has a column PARTITION_DATE . ITEMDELIVERY_ID and PARTITION

Optimistic concurrency out of session in NHibernate

风流意气都作罢 提交于 2020-01-03 05:05:09
问题 I'm having trouble implementing optimisitc concurrency in NHibernate in a meaningful way in a web application. Here is the desired scenario: User A opens a form to edit a record User B opens the same form to edit the same record User A saves their data User B tries to save their data but get a warning that the data has been updated. A common scenario. Here is the update code and entity mapping file: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Entities" assembly="Domain">

Class-cache not used when getting entity by criteria

元气小坏坏 提交于 2020-01-03 04:14:23
问题 I've set class-cache in nhibernate.cfg.xml file. When I get my entity by Id, I don't see SQL requests once object is loaded. But when I fetch entity using criteria, there is always SQL queries... EDIT: I guess this answers my question: http://www.javalobby.org/java/forums/t48846.html Let's say that we wanted to lookup entries based on a more complex query than directly by ID, such as by name. In this case, Hibernate must still issue an SQL statement to get the base data-set for the query. So,

NHibernate Mapping for User Roles and Privileges

落花浮王杯 提交于 2020-01-03 03:57:10
问题 The Scenario I've been banging my head against the wall trying to figure out the correct mapping for 3 entities: User, Role, and Privilege. In my application, Users can have Privileges, which just give a user additional permissions. Users can also have Roles which are essentially privileges that require additional properties. For instance, a user might have a role of "Application Administrator" in which case the ApplicationAdministratorRole.cs would need a property to contain the list of

Is there a way to disable Castle Active Record validation for an nhibernate session / active record scope

浪子不回头ぞ 提交于 2020-01-03 03:42:22
问题 Is there a way to disable Active Record validation for an nhibernate session / active record scope? I have a scenario whereby we are performing deletion of a large number of items - and in some cases customers have data in their database that will not pass validation (it was captured prior to new validation rules being introduced, or due to manual manipulation of the database etc.) When deleting, due the way the database is constructed, some validation checks on existing entities occur, and

Specifying select-before-update with Fluent NHibernate?

半城伤御伤魂 提交于 2020-01-03 03:23:07
问题 I'm trying to specify the "select-before-update" attribute in a ClassMap using Fluent NHibernate, but I'm not finding much on the web that shows what the right way to do it is. Does anyone know how to achieve this with Fluent NHibernate? Thanks! 回答1: SelectBeforeUpdate() in your ClassMap . 来源: https://stackoverflow.com/questions/1784379/specifying-select-before-update-with-fluent-nhibernate

Implication of using dynamic Expression<Func<T,X>> in NHibernate

♀尐吖头ヾ 提交于 2020-01-03 02:56:14
问题 Basically in my application, I am using the following code to build my expression depending on the selection on the page. Expression<Func<T, bool>> expr = PredicateBuilder.True<T>(); expr = expr.And(b => b.Speed >= spec.SpeedRangeFrom && b.Speed <= spec.SpeedRangeTo); ... It has the tendency to end up with a long expression with multiple "or" and "and" conditions. Once I have finished building the expression, I passed it on to my repository which looks like the following: var results =

Active Record or NHibernate generating invalid Sql for paging on SqlQuery

落爺英雄遲暮 提交于 2020-01-03 02:48:05
问题 When applying Paging (using SetFirstResult and SetMaxResults ) to an ActiveRecord SqlQuery , with nHibernate 2.1.1 GA and ActiveRecord 2.0.1 the following sql is generated: SELECT TOP 40 FROM (, ROW_NUMBER() OVER(ORDER BY account.Name, account.State) as __hibernate_sort_row select account.Name <rest of query> ) as query WHERE query.__hibernate_sort_row > 40 ORDER BY query.__hibernate_sort_row This errors and moreover doesn't run in sql... whereas it should be SELECT TOP 40 * FROM ( SELECT ROW