nhibernate-mapping

NHibernate with nothing but stored procedures

旧时模样 提交于 2020-01-13 06:42:08
问题 I'd like to have NHibernate call a stored procedure when ISession.Get is called to fetch an entity by its key instead of using dynamic SQL. We have been using NHibernate and allowing it to generate our SQL for queries and inserts/updates/deletes, but now may have to deploy our application to an environment that requires us to use stored procedures for all database access. We can use sql-insert, sql-update, and sql-delete in our .hbm.xml mapping files for inserts/updates/deletes. Our hql and

NHibernate mapping not adding ON DELETE CASCADE option to foreign key reference

送分小仙女□ 提交于 2020-01-11 05:14:08
问题 Here's my NHibernate mapping. <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="HelloNHibernate" namespace="HelloNHibernate"> <class name="Showing" table="showing"> <id name="Id" column="showing_id"> <generator class="identity"/> </id> <many-to-one class="Theater" name="Theater" column="theater_id" foreign-key="fk_showing_theater_theater_id" cascade="delete" lazy="false" fetch="join"/> <many-to-one class="Movie" name="Movie" column="movie

How do I get fluent nhibernate to create a varbinary(max) field in sql server

和自甴很熟 提交于 2020-01-09 07:53:03
问题 How can I get fluent nhibernate to create a varbinary field in a sql server 2005 table that uses a field size of varbinary(max)? At the moment I always get a default of varbinary(8000), which isn't big enough as i'm going to be storing image files. I've tried using CAstle.ActiveRecord but havent had any success yet. [ActiveRecord] public class MyFile : Entity { public virtual string FileName { get; set; } public virtual string FileType { get; set; } public virtual int FileVersion { get; set;

Splitting NHibernate entity row storage across multiple tables

社会主义新天地 提交于 2020-01-07 05:40:13
问题 In our NHibernate setup, we have a Listing entity. For DB performance reasons, we want to split the storage of it into multiple tables, by country (the way the site is set up, no-one can ever search in more than one country at a time). So, Listing_US, Listing_FR, etc. Two questions, the first far more important than the second: Is there any way NHibernate can do this mapping for me? Presumably it would be based around an internal field that gets generated on the Get() (where I'd pass in the

Hibernate Annotatoin - How to Join Three Tables with many to many relationship

孤人 提交于 2020-01-06 15:13:39
问题 I have 3 Entity USER, APPLICATION, and ROLE . I want there IDs to be joined in a table named USER_APP_ROLE(user_ID, application_ID, role_ID) with many to many relationship between them. Reason I want this structure is- I have requirement of allowing the user to work on multiple application with multiple roles. I have done the following codes: User.java @ManyToMany (targetEntity=Role.class) @JoinTable(name="USER_APPLICATION_ROLE", joinColumns=@JoinColumn(name="USER_ID"), inverseJoinColumns=

fluent NHibernate: many-to-many relationship with Product to Product

为君一笑 提交于 2020-01-05 10:18:07
问题 fluent NHibernate: many-to-many relationship with Product to Product.how i can implement it on asp.net mvc public class Product { public virtual int Id { get; set; } public virtual IList<Product> ManyProduct { get; set; } } Mapping public class ProductMap : ClassMap<Product> { public ProductMap() { Id(x => x.Id); Map(x => x.ImageUrl); } HasManyToMany(x => x.ManyProduct) .Cascade.All() .Table("ProductInProduct"); } 回答1: You don't specifically say what is wrong but your HasManyToMany definition

NHibernate Mapping Attributes + Dirty Checking

橙三吉。 提交于 2020-01-05 07:55:08
问题 I have problems with NHibernate updating some of my entities when this is not supposed to happen (dirty checking). As I use NHibernate.Mapping.Attributes to map my classes, I have found that there is a parameter "Check" to the element "Class" of NHMA. I would like to know if I can turn off dirty checking by setting this parameter to false or something (the required type for this parameter is string, so it may not be that). Any help would be appreciated ! 回答1: Firstly, this is not something

How to Unit Test when stored procedures are used by NHibernate Mapping

寵の児 提交于 2020-01-05 07:14:09
问题 I've asked about how to inject stored procedures support when working with Views in SQL Server. How to use stored procedures in NHibernate for Create/Update when working with database view Here's a piece of mapping file: <sql-insert> exec sp_cycle_insert ?,?,? </sql-insert> <sql-update> exec sp_cycle_update ?,?,?,?,?,? </sql-update> <sql-delete> raiserror ('Cycle can not be deleted', 10, 1) </sql-delete> So, I've done the refactoring, etc, and I run my tests.... All failed. There reason is

How to Unit Test when stored procedures are used by NHibernate Mapping

早过忘川 提交于 2020-01-05 07:14:04
问题 I've asked about how to inject stored procedures support when working with Views in SQL Server. How to use stored procedures in NHibernate for Create/Update when working with database view Here's a piece of mapping file: <sql-insert> exec sp_cycle_insert ?,?,? </sql-insert> <sql-update> exec sp_cycle_update ?,?,?,?,?,? </sql-update> <sql-delete> raiserror ('Cycle can not be deleted', 10, 1) </sql-delete> So, I've done the refactoring, etc, and I run my tests.... All failed. There reason is

Map Entities to self-joined Table by Id

≯℡__Kan透↙ 提交于 2020-01-05 05:48:04
问题 My legacy table "AllData" has those columns: Id, Title, LookupColumn1Id My entities: public class BaseEntity { public virtual int Id { get; set; } public virtual string Name { get; set; } } public class Employee: BaseEntity { public virtual int DepartmentId { get; set; } public virtual string DepartmentName { get; set; } } public class Department: BaseEntity { public virtual int HeadManagerId { get; set; } } I want to generate SELECT like this: SELECT EmployeeTable.Title, DepartmentTable.Id,