nhibernate

NHibernate and interceptors - measuring/monitoring SQL round-trip times

本秂侑毒 提交于 2019-12-31 02:18:26
问题 In order to get early-warning of a slow or potentially slow areas, I'd like to have an Interceptor for NHibernate that can act as a performance monitor, so that any database operation that takes more than a given time raises an event and (importantly) a full stacktrace into the application's logs. Interceptors seemed to be a good window into this. However, having experimented, there doesn't seem to be anyway to catch a "just-back-from-SQL" event: OnPreFlush and OnPostFlush work on full

nhibernate 2.0 Efficient Data Paging DataList Control and ObjectDataSource

拟墨画扇 提交于 2019-12-31 02:09:25
问题 How would I do what Scott has done in one call using nHibernate 2 ObjectDataSource http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx below is my Data access method public IList GetListOfUser(int rows, int pageIndex) { IList userList = null; using (ITransaction tx = _session.BeginTransaction()) { try { userList = _session.CreateQuery("Select u from User u where u.DateSubmitted is not null") .SetFirstResult(rows * (pageIndex - 1) + 1) .SetMaxResults(rows) .List(); tx.Commit(); }

How to map composite-id with fluent nhibernate using an interface?

安稳与你 提交于 2019-12-31 02:08:08
问题 I'm trying to switch out .hbm mappings to fluent mappings and have a problem with the mapping of composite-ids and the usage of Interfaces the Class looks as follows: public class ClassWithCompositeId { public virtual IKeyOne KeyOne { get; set; } public virtual IKeyTwo KeyTwo { get; set; } } our hbm mapping looks like this: <hibernate-mapping ...> <class name="ClassWithCompositeId" table="t_classwithcompositeid"> <composite-id> <key-many-to-one name="KeyOne" column="colkeyone" class="company

One to Many mapping with an intermediate table

本小妞迷上赌 提交于 2019-12-30 11:34:06
问题 I thought I had this one pegged by mapping the intermediary table as a HasMany and between intermediary and child as HasOne, however HasOne expects to share a key. (No Inverse option.:[ ) Anyhow, the relational structure I have: Address (Child) AddressId ..Address Fields AddressCustomer (Intermediary) AddressCustomerId AddressId CustomerId Customer (Parent) CustomerId ..Customer Fields Why I have this intermediary table instead of a normal 1-many? Because there will be other entities that

NHibernate 2 + Fluent Nhibernate medium trust

妖精的绣舞 提交于 2019-12-30 11:05:38
问题 Will NHibernate 2 and\or Fluent Nhibernate work in a medium trust environment. If not are there any work-arounds? 回答1: Not sure about fluent NH - I assume it should - it just translates to XML. With NH itself you will loose bytecode optimization, all your setters/constructors will need to be public. If you need to use lazy loading you will have to have your proxies generated with build (NH proxy generator). Should you have some permissions enabled in your medium trust settings you can relax

nhibernate query all objects implementing an interface

大兔子大兔子 提交于 2019-12-30 10:34:56
问题 For example, if you have an Apple : IWhatever, and an Orange : IWhatever and you want to find both of them because they are IWhatevers, what do you need to do in NHibernate? Is it completely dependent on the HQL or criteria query, or is there something you must do in the mapping also? If there is a mapping requirement, can Fluent NHibernatee support it? 回答1: You could do a UnionSubClass mapping. Unforntunately it is unsuported in Fluent. You mapping would be something like: <class name=

nhibernate query all objects implementing an interface

最后都变了- 提交于 2019-12-30 10:34:19
问题 For example, if you have an Apple : IWhatever, and an Orange : IWhatever and you want to find both of them because they are IWhatevers, what do you need to do in NHibernate? Is it completely dependent on the HQL or criteria query, or is there something you must do in the mapping also? If there is a mapping requirement, can Fluent NHibernatee support it? 回答1: You could do a UnionSubClass mapping. Unforntunately it is unsuported in Fluent. You mapping would be something like: <class name=

Filter child collection returned with Aggregate Root using Nhibernate

。_饼干妹妹 提交于 2019-12-30 10:00:20
问题 I'm trying filter the child collection of an aggregate root when loading it with Nhibernate. Load a Customer with all their Orders that have been shipped. Is this possible? 回答1: Well, you can expose properties that are filtered in the map, like so: <bag name="shippedOrders" ... where="Status == 'Shipped'" > <key column="CustomerId" /> <one-to-many class="Order" /> </bag> The 'where' attribute is arbitrary SQL. Theoretically you could have two properties of Customer, Orders and ShippedOrders.

NHibernate TransactionScope issue with Oracle 11g

烈酒焚心 提交于 2019-12-30 09:55:19
问题 The following code snippet works fine with SQL Server 2008 (SP1) but with Oracle 11g the call to session.BeginTransaction() throws an exception with the message ‘Connection is already part of a local or a distributed transaction’ (stack trace shown below). Using the '"NHibernate.Driver.OracleDataClientDriver". Has anyone else run into this? using (var scope = new TransactionScope()) { using (var session = sessionFactory.OpenSession()) using (var transaction = session.BeginTransaction()) { //

Fluent NHibernate and composite ID with single column name

萝らか妹 提交于 2019-12-30 09:55:13
问题 I've crossed posted this in the FNH Google Group but here's the scoop: I have a table in a legacy database that has a composite ID. Well, the PK is implied since the table doesn't actually have a PK defined, but the natural PK is the combination of the WORKORDERID and IMAGEPATH columns: CREATE TABLE [WORKORDERIMG]( [WORKORDERID] [varchar](50) NULL, [IMAGEPATH] [varchar](250) NULL, [WOTASKID] [numeric](10, 0) NULL, [ATTACHEDBY] [nvarchar](100) NULL, [COMMENTS] [nvarchar](256) NULL,