nhibernate

Composite key with sequence

大城市里の小女人 提交于 2019-12-24 06:49:16
问题 I have a composite key in my table and part of it needs to be generated by a sequence. I tried the following, but it doesn't work - the line that sets the sequence name seems to be overridden by the composite key declaration that follows: mapping.Id(x => x.Id).GeneratedBy.SequenceIdentity("SQ_TRANSFORM_ITEMDEL_IDDID"); mapping.CompositeId().KeyProperty(x => x.Id, "ITEMDELIVERYDETAIL_ID") .KeyReference(x => x.ItemDelivery, "ITEMDELIVERY_ID", "PARTITIONDATE"); How to solve that problem? 回答1:

Escaping a question mark character in a column name in NHibernate

点点圈 提交于 2019-12-24 06:37:55
问题 I have an entity with a property whose column name contains a question mark. How do I map the column name so that an HQL query will correctly generate SQL with the column name wrapped appropriately (i.e. [] for SQL Server) instead of substituting a parameter for the question mark? I have tried wrapping the column name in backticks or square brackets but this doesn't work. 回答1: Backticks work fine for me. Remember to use them only in the mapping file, not in the HQL: <property name="Data1"

Inserting byte[0] into a NOT NULLABLE column in Oracle DB Table

↘锁芯ラ 提交于 2019-12-24 06:35:20
问题 I have a table DOCUMENTS in Oracle DB with the below description create table DOCUMENTS ( DOC_ID NUMBER not null, DOCUMENT BLOB not null, DOC_URL VARCHAR2(4000) ) This is a simple table which is used to store images from multiple sources. From one of the source, the requirement is to just insert the HTTP Path of the image without the DOCUMENT (Document would be NULL). As the column is defined as NOT NULL in the table, I was trying to overcome the constraint by inserting an empty blob into the

Nhibernate in asp,net ISession help

假装没事ソ 提交于 2019-12-24 06:24:17
问题 We're using nhibernate in and asp.net MVC application. We are implementing the Session per Request pattern, via a httpModule. It looks pretty straight forward, but when we run with NHibernate Profiler, it clearly shows that the sessions are never getting closed. the pattern seems straight forward...but I don't understand why the sessions are never closing. here's the code i think is important. set up the event handler: context.EndRequest += new EventHandler(this.context_EndRequest); in the

NHibernate: How to set DynamicUpdate on all Entities?

旧街凉风 提交于 2019-12-24 05:59:17
问题 How can I set DynamicUpdate and DynamicInsert on all my entities? It works perfectly when I put it together with my mapping code, but I would like to specify it only once for my entire project. I could not find an option when creating the Session or in the Configuration. Any ideas? 回答1: I use fluent nhibernate so I would change them like this: var fluentConfiguration = Fluently.Configure(NHibernate.Cfg.Configuration().Configure()) .Mappings(m => m.FluentMappings .AddFromAssemblyOf<OrderMap>()

For SQL select returning more than 1 value, how are they sorted when Id is GUID?

痞子三分冷 提交于 2019-12-24 05:33:07
问题 I'm wondering how SQL Server orders data that is returned from a query and the Id columns of the respective tables are all of type uniqueidentifier. I'm using NHibernate GuidComb when creating all of the GUIDs and do things like: Sheet sheet = sheetRepository.Get(_SheetGuid_); // has many lines items IList<SheetLineItem> lineItems = sheet.LineItems; I'm just trying to figure out how they'll be ordered when I do something like: foreach (SheetLineItem lineItem in lineItems) I can't see to find

For SQL select returning more than 1 value, how are they sorted when Id is GUID?

巧了我就是萌 提交于 2019-12-24 05:32:23
问题 I'm wondering how SQL Server orders data that is returned from a query and the Id columns of the respective tables are all of type uniqueidentifier. I'm using NHibernate GuidComb when creating all of the GUIDs and do things like: Sheet sheet = sheetRepository.Get(_SheetGuid_); // has many lines items IList<SheetLineItem> lineItems = sheet.LineItems; I'm just trying to figure out how they'll be ordered when I do something like: foreach (SheetLineItem lineItem in lineItems) I can't see to find

C# NHibernate Simple Question

ぃ、小莉子 提交于 2019-12-24 04:12:45
问题 I'm using NHibernate -driven repository, Fluent mappings and attempt to use Linq to NHibernate . But for some simple query like this Retrieve<XValue>(x => (x.Timestamp.CompareTo(start) >= 0 && x.Timestamp.CompareTo(end) <= 0 )); // 'Retrieve' here acts simply as 'session.Query<T>().Where(expression);' I get the following result: System.NotSupportedException: Int32 CompareTo(System.DateTime) I don't know why, but CompareTo operations aren't projected to the database and the output is also kind

NHibernate.Mapping Exception. No persister for Namespace.className

丶灬走出姿态 提交于 2019-12-24 04:09:58
问题 Have looked at 4 stackoverflow posts on the same issue but couldn't find a solution. My main program: using System; using System.IO; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Threading.Tasks; using NHibernate; using NHibernate.Cfg; using NHibernate.Cfg.MappingSchema; using NHibernate.Dialect; namespace NhibernateORM { public class Layout { public int Id { get; set; } public string Name { get; set; } public double xCoordinate

Override lazy loading behavior 'lazy=false'

我怕爱的太早我们不能终老 提交于 2019-12-24 04:04:07
问题 I would like to override the default lazy loading behavior which is set in mappings as 'lazy=false'. Can't change it as many parts of existing application depend on this setting. After spent some hours on it I didn't find a solution so I'm asking here. How to do this? What I want to achieve is to fine tune my query to load only what is needed. This is what I've tried already: Using QueryOver api: var properties = session.QueryOver<Property>() .Fetch(prop => prop.Transactions).Eager .Fetch