[nhusers] L2 Caching crash with AppFabric

2012-04-18 Thread Graham Bunce
Hi, I'm using NHibernate L2 caching with AppFabric and using the AppFabric caching provider written by Simon Taylor on GitHub. This works fine most of the time but every so often (after 5 minutes or so in the test environment) I'll get a crash within the provider. It's difficult to replicate in d

[nhusers] Re: How to tell an entity know what session loaded it

2011-06-18 Thread Graham Bunce
Mohammed, Thanks for the reply.We have thought of registering a session as the "active" one so that lower level entites use this. It will work, much like it will work if we pass the current session into the entity method. Unfortunately it depends on the developer remembering to register a session

[nhusers] How to tell an entity know what session loaded it

2011-06-18 Thread Graham Bunce
Hi, I'm updating a framework we have around NHibernate and we're moving it from a pattern based around Open Session In View (and we only use one session per thread for all access) to one that allows us to open and maintain multiple sessions per thread. We use this session in an "ambient" manner, i

[nhusers] Re: Clarification on NH-2596 of PreUpdate vs OnSaveOrUpdate semantics

2011-04-09 Thread Graham Bunce
And just to clarify, this isn't a complaint at anyone. NH is a free product that is as good as anything else on the market, if not better, and it's worked on unpaid by the developers, so those of us who use it should be grateful for this and that NH is still an active product. On the flip side, th

[nhusers] Re: Clarification on NH-2596 of PreUpdate vs OnSaveOrUpdate semantics

2011-04-09 Thread Graham Bunce
Scott, To jump in here. I wrote the article you referred to in your reply to Fabio, and tbh, I wouldn't consider it official NHibernate documentation. It was written a long time ago as an example of the things you could do with the events,when documentation on the interfaces as opposed to the old

[nhusers] Re: [Link] [Blog] "NHibernate 3.1 on NuGet - Important Details"

2011-03-13 Thread Graham Bunce
Mohamed, As an aside, many thanks for the blog entry. I saw the Nuget feed and was instantly confused as to why I shouldn't install it until I came here :) May I suggest that this should actually be a wiki entry on nhforge? Fabio: . or some helper text be put in the Nuget feed description (e.

[nhusers] Re: eager loading

2011-02-15 Thread Graham Bunce
I believe that unless you disable lazy loading in the mapping (which isn't the best of ideas) then a Get will not "get" the object tree from the database in one hit, unless you edit the collection mapping to do this, e.g. fetch="join" etc. See http://nhforge.org/blogs/nhibernate/archive/2009/04/13/

[nhusers] Re: Zombie connections with Hilo and avoidance options?

2011-02-01 Thread Graham Bunce
> Are you using System Transactions and/or explicit NH transactions? Explicit NH Transactions > What isolation level are you using? Can't remember, I'm not at my desk atm. The default for SQL Server 2005 > Are you sharing sessions across threads? No, I don't believe so > Could you provide the

[nhusers] Zombie connections with Hilo and avoidance options?

2011-01-31 Thread Graham Bunce
Hi, I'm having a few issued with deadlocks that seem to eventually cause Zombied connections. I'm using NH 2.1.2GA and SQL Server 2005. My scenario is thus: I have a multi-threaded process that scans a database table and creates a bunch of inserts. All inserts are logicially distinct sets of dat

[nhusers] Re: Incorrect use of NH with transaction Scope DOESN'T leak...??

2011-01-17 Thread Graham Bunce
Ok, that's a reasonable way forward for now, thanks! -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com. To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com. F

[nhusers] Re: Incorrect use of NH with transaction Scope DOESN'T leak...??

2011-01-16 Thread Graham Bunce
HI Jason, thanks for the reply. An upgrade to NH3 isn't really possible yet. We use quite a bit of NH- Linq and I've read the new provider fails where the last one succeeds, which would be a bit of a regression test problem. I'm waiting for NH 3.1 before I consider upgrading. I'm a little confuse

[nhusers] Incorrect use of NH with transaction Scope DOESN'T leak...??

2011-01-13 Thread Graham Bunce
Hi, I'm using NH 2.1.2GA and am attempting to reproduce the leaky connection bug with Transaction Scope. I'm looking at this as our existing architecure doesn't use the recommended pattern of TransactionScope -> Open Session -> Start NH transaction, and although we get no issues, I've always known

[nhusers] Re: Hi-lo generator and multiple processes - is this a potential race-condition?

2010-09-14 Thread Graham Bunce
with an example hilo definition of: CREATE TABLE [dbo].[hibernate_unique_key]( [next_hi] [int] NOT NULL, [Entity] [varchar](50) NOT NULL ) ON [PRIMARY] GO and an example mapping... 2 Entity='Advert' . you need a row for each e

[nhusers] Re: Hi-lo generator and multiple processes - is this a potential race-condition?

2010-09-14 Thread Graham Bunce
We use the where parm after a migration from identity. It's pretty straightforward. The HiLo table definition is: CREATE TABLE [dbo].[hibernate_unique_key]( [next_hi] [int] NOT NULL, [Entity] [varchar](50) NOT NULL ) ON [PRIMARY] GO and an example mapping is:

[nhusers] Re: Parallel.Forech using NHibernate

2010-09-07 Thread Graham Bunce
... however if you did want to do this then you'd need some framework to manage the sessions for you. the best way may be to wrap each Create within a method that manages the session for you e.g. (semi pseudo-code) Parallel.ForEach(() => { ServiceLayer.Create(entity); }; ServiceLayer.Create(T en

Re: Parameter lengt/precision/scale attributes (WAS: RE: [nhusers] NHibernate Performance Analysis via DBA)

2010-09-05 Thread Graham Bunce
On Sep 5, 11:02 pm, José F. Romaniello wrote: > I think this is the place to open issues/bugs:http://connect.microsoft.com/ Which, to be fair, was in the original poster's mail and it states MS will not fix it. Therefore, as much as that decision is BS, the onus is on the NH community to work-aro

Re: Parameter lengt/precision/scale attributes (WAS: RE: [nhusers] NHibernate Performance Analysis via DBA)

2010-09-05 Thread Graham Bunce
Frans... > How does NH now set the parameter type for a Time or Date parameter? > As the value is always of type System.DateTime.. It doesn't. http://216.121.112.228/browse/NH-2207 I for one would wish NH would get this sorted. I *know* it's MS problem and it's their fault but sometimes produc

[nhusers] Convert HQL to Criterion because of LockMode...

2010-09-02 Thread Graham Bunce
All, I have an HQL query built up over several steps that works quite well. However, I now need to add some locking hints to the query via SetLockMode. I can't get this to work as the alias keeps failing. My HQL is something like this (NH 2.1) SELECT Count(*) FROM Transaction MT WHERE MT.From.L

[nhusers] Re: "error performing isolated work" with HiLo

2010-07-27 Thread Graham Bunce
Hmm... I am using a single HiLo table with a lookup column to identify the entity. I wonder if that's getting confused somehow? -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscr

[nhusers] "error performing isolated work" with HiLo

2010-07-23 Thread Graham Bunce
Hi all, I've converted a project from SQL Server identity primary key columns to HiLo. So far all seems to work ok. However there is one part of my application that performs a large number of inserts across a wide range of data. This data is logically isolated so I've split the code into threads

[nhusers] Re: Invalid case of Collection or HashSet to ISet exception on save

2010-07-02 Thread Graham Bunce
nvm, it had been mapped as a List not a Set. The only one in the application the be different :p -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email

[nhusers] Re: Invalid case of Collection or HashSet to ISet exception on save

2010-07-02 Thread Graham Bunce
ok... an update to this. I have a new object. This object has a child collection which is an intitialised empty iesi hashedset. Perform a Save on this parent and NH crashes: Unable to cast object of type 'Iesi.Collections.Generic.HashedSet`1[iTrace.Domain.Entities.LocationOrderDay]' to type 'Sys

[nhusers] Re: Invalid case of Collection or HashSet to ISet exception on save

2010-07-01 Thread Graham Bunce
>"forward" well... "forward" is a mere hope in some cases. lol. That's is certainly true. We can hope though... >I saw somebody trying to go from NH to EF and "forward" is not exactly his >feeling. Well, EF is a non starter at the moment but it's something that senior managers keep questionin

[nhusers] Re: Invalid case of Collection or HashSet to ISet exception on save

2010-07-01 Thread Graham Bunce
Oskar : >Maybe we mean different thing with "repository", but I consider the repository >concept (not necessarily the implementation) to be part of the domain model. No I don't think we do. My domain layer uses BCL collections and accesses my repository through an interface. The only rule my repo

[nhusers] Re: Invalid case of Collection or HashSet to ISet exception on save

2010-07-01 Thread Graham Bunce
Fabio - I know what you mean and I'm coming to the state of mind of "I'm a bit fed up of trying to seperate repository from domain so just go with it". However the problem is that although iesi is open source and is not an NH specific dll, it's not a BCL collection. So far I've strictly enforced d

[nhusers] Re: Invalid case of Collection or HashSet to ISet exception on save

2010-06-30 Thread Graham Bunce
Fabio, Thank you for the more helpful update and link to JIRA. Perhaps Ayende can update that blog entry to say that actually you CAN'T use HashSet and must still use the Iesi HashedSet. Although it will be a bit of an OMG change for .NET 4.0, it would be nice as (hopefully) it will enable greate

[nhusers] Re: Is there a way to 'un-initialize' a proxy class (or achieve the same effect)?

2010-06-30 Thread Graham Bunce
on the session object, try this: entity = session.GetSessionImplementation().PersistenceContext.Unproxy(entity); -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this

[nhusers] Re: Invalid case of Collection or HashSet to ISet exception on save

2010-06-30 Thread Graham Bunce
Thanks for the "answers". As I said in my post, it also fails if I use HashSet AS PER AYENDE'S POST Unable to cast object of type 'System.Collections.Generic.HashSet`1[iTrace.Domain.Entities.Operation.MovementTransactionItem]' to type 'Iesi.Collections.ISet'. You telling me we MUST use the IESI

[nhusers] Invalid case of Collection or HashSet to ISet exception on save

2010-06-30 Thread Graham Bunce
All, I've come across an odd situation with NH and the Version settings. My App uses generic ICollections and map these to sets. It works fine without any problems. However, if i add the Version setting to the mapping file I get intermittent problems such as: Unable to cast object of type 'Syste

[nhusers] SaveOrUpdateCopy with set causes unsaved entity error

2010-06-03 Thread Graham Bunce
All, I have a parent object "Location" that has a set of child objects "Account". 9/10 times these are treated as distinct entities so I have logically placed them in seperate "domain aggregates". This means I have cascade="none" from the location to the account set. However, when I create a loc

[nhusers] Re: Connection leak when ambient transaction aborts

2010-06-03 Thread Graham Bunce
>Let me guess: you're using identity. > > Diego Can I ask if this makes a difference to the pattern? I'm NOT using NH txn's as, like most people, I ran the tests, it worked and so, far have not had any problems. I'm using GUID.COMB and FlushMode.Never though. IMO this whole issue needs clearing

[nhusers] Trace object causing object references an unsaved transient instance error

2010-05-30 Thread Graham Bunce
All, I'm trying to track the the object causing this error: "NHibernate.TransientObjectException : object references an unsaved transient instance - save the transient instance before flushing. Type: Entities.Allocation.OrderItemAllocation, Entity: Entities.Allocation.OrderItemAllocation". I'm t

[nhusers] Re: Mapping System.DayOfWeek enum causes

2010-05-21 Thread Graham Bunce
Thanks Paulo. My immediate reply was to John. That seems to work ok - looks like NH is more intelligent than I give it credit for. Will this still prevent ghosts, i.e. NH loads an object, does a cast to a different type, so assumes it changed when in fact it hasn't? -- You received this me

[nhusers] Re: Mapping System.DayOfWeek enum causes

2010-05-21 Thread Graham Bunce
Cheers, found this and yes, I've looked on google. I'm mapping several other enums to properties perfectly well using the method listed in my post (using NH 2.1.2GA btw). I'm not sure, but I think the post you listed was only necessary to NH 1.2 GA? My issue not with mappings enums but with mappin

[nhusers] Mapping System.DayOfWeek enum causes

2010-05-21 Thread Graham Bunce
Hi, I'm trying to map a System.DayOfWeek enum to a database int field. My mapping as as follows: When NH verifies the mapping I get a TypeInitializationException and a message of: "Could not determine type for: System.DayOfWeek, System, for columns: NHibernate.Mapping.Column(FirstDayOfTheWeek

[nhusers] Re: NHibernate and .Net 4.0

2010-05-12 Thread Graham Bunce
It would be great, but too soon. Many people want a full Linq provider who are not able to upgrade to .NET 4.0 straight away. IMO on way would be a release of 3.0.0 as .NET 3.5 and an immediate branch to (e.g. 4.0.0) for a .NET 4.0 version. Maintain 3.x in .NET 3.5 as a bug patch version alongside

[nhusers] Re: .NET developer need some help about nhibernate

2010-05-03 Thread Graham Bunce
Anything in particular? -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com. For more options, visit this g

[nhusers] Re: Domain model using Interfaces - how to map in nHibernate

2010-05-03 Thread Graham Bunce
If you're mocking data then now, probably no point in an interface - except maybe unless you wish to enforce a specific layer boundary that can be replaced/mocked. Even then, mocking POCO's seem a bit pointless. However if you wish to avoid the anemic data model (i.e. pure POCO's with behavour in

[nhusers] Re: Create custom configuration (or custom properties on config)

2010-05-02 Thread Graham Bunce
Fabio pt2. Thanks for the links btw... it isn't that tricky at all now I can see an example. I misunderstood your comment re: configuration blocks. NH saves the day again! -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send e

[nhusers] Re: Create custom configuration (or custom properties on config)

2010-05-02 Thread Graham Bunce
Thanks Fabio - I much prefer the answer "yes", even if its tricky ;) If nothing else, I get to learn more about the inside of NH, which can only be a good thing. Looking forward to NH 3.0.0 :) -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post

[nhusers] Re: Domain model using Interfaces - how to map in nHibernate

2010-05-02 Thread Graham Bunce
>AFAIK, one limitation of using proxy I encounter is that access to data >model limited through public property. For example, I can't inject data when >loading an instance through its private field. True, you can't as the interface doesn't have the property you need. You can do things like check i

[nhusers] Re: Create custom configuration (or custom properties on config)

2010-05-02 Thread Graham Bunce
Thanks for the opinions. Yes, I'd thought of both of those options already. However my extension is to NHibernate behaviour, i.e. If this configuration setting = true then extend NHibernate so that it does not perform implicit dirty checking (as per the NH Add Ins process Fabio wrote) otherwise us

[nhusers] Create custom configuration (or custom properties on config)

2010-05-01 Thread Graham Bunce
Hi, I'm trying to add custom properties to the hibernate.cfg file to control additional behaviour that we have extended in NH. Unfortunately the NH XSD forces the Configure() step to fail as it doesn't recognise my configuration. I'd like to extend the configure class to, perhaps, intercept the c

[nhusers] Re: Domain model using Interfaces - how to map in nHibernate

2010-05-01 Thread Graham Bunce
If you're going to interface everything then you might want to consider making your proxies from the interface instead of the concrete class. It works, but it's not without its problems as the proxy doesn't inherit from the concrete class but from its own representation of the interface (at least i

[nhusers] Re: My point of view about nhforge.org

2010-04-25 Thread Graham Bunce
Fabio, Nobody doubts your contribution to the NH ecosystem but if the key contributors to NH (you, Ayende, Tuna etc.) don't use NH Forge where is the momentum to drive people to the site, making them more aware of it, and then contributing there own posts? If cross posting is the best we can hope

[nhusers] override how proxy compares objects

2010-04-09 Thread Graham Bunce
All, I have a system setup to generate proxies based on an interface. This causes me a problem when I use the standard collection compare methods (e.g. Contains(obj), Remove(obj) etc.) If I pass a proxy'd object to a collection Remove method (where the collection is a generic type of the concrete

[nhusers] Re: Bugs linked to lazy loading/proxies

2010-03-15 Thread Graham Bunce
Sorry, too tired to read the full post and work out what's going on for you but look at this thread that I raised with similar questions: http://groups.google.com/group/nhusers/browse_thread/thread/fce0810bee14d5b3# A proxy will always be a proxy unless you force replace it (I think) -- You rec

[nhusers] Re: Eager loading fetches duplicates fields

2010-03-09 Thread Graham Bunce
That may be the SQL produced but I would expect you not to get duplicate items in the collection? If so, then that's the way it works. You could change your mapping (I think) to do two seperate selects in one database round trip. I'm sorry, but I can't remember the mapping option to do that. If y

[nhusers] Re: Multiple Classes per File

2010-03-09 Thread Graham Bunce
You can also use the hibernate.cfg file to have a list of assemblies, each containing the embedded resources you need. I'm not sure if there is a way for NH to read the hbm at runtime, but I haven't looked too hard tbh. -- You received this message because you are subscribed to the Google Groups

[nhusers] Re: NH force conversion of proxy to concrete class

2010-03-09 Thread Graham Bunce
Thanks again Diego. It is a framework but the main issues I'm having is when I have an interface that (e.g.) restricts properties to getters but the concrete class has an internal setter to allow controller methods to hook things together. These controller methods take in an interface but need to

[nhusers] Re: NH force conversion of proxy to concrete class

2010-03-09 Thread Graham Bunce
To extend this slightly, is there an NHibernate IsProxy method? I've looked at the NHibernateProxyHelper but nothing in there. The above almost gave me what I needed but in some edge cases I may have an initialised proxy that will pass an NHibernateUtil.IsInitialized check but still not cast to a

[nhusers] Re: NH force conversion of proxy to concrete class

2010-03-09 Thread Graham Bunce
Thank you Diego :) -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com. For more options, visit this group

[nhusers] Re: NH force conversion of proxy to concrete class

2010-03-09 Thread Graham Bunce
By unwrap I assume you don't mean an NH function called "unwrap" but I need to write my own converter to take the proxy to a concrete class - i.e. create a concrete and copy the properties over? I'm using NH 2.1.3GA so I guess the new lazy="no-proxy" isn't available. There is nothing in NH to do

[nhusers] NH force conversion of proxy to concrete class

2010-03-09 Thread Graham Bunce
All, I'm using proxies based on an interface, e.g. When I do a Session.Load (or anything that creates a proxy) then the proxy is based on the interface, IThing. Any code such as this: Thing obj = (Thing)proxy; will fail as an "IThing" proxy from NHibernate does not inherit from "Thing".So f

[nhusers] Re: Session.Load proxy accesses DB even if you just access the ID

2010-03-07 Thread Graham Bunce
lol, wish google had Edit. and now a workaround. IEntity is a { get; set } for assigning the ID during hydration from the DB. If I add " new ID { get; }" to IDomain, the problem goes away. Unfortunate, but less of a problem than my whole application stack being screwed :) Still sounds

[nhusers] Re: Session.Load proxy accesses DB even if you just access the ID

2010-03-07 Thread Graham Bunce
Ok, recreated it and will raise a JIRA. However, it's a bit of an "edge"case (but unfortunately fundamental to our application stack) so before I do, any comments appreciated... To get it to fail I have the following: public interface IEntity (containing the ID) public interface IDomain : IEntity

[nhusers] Re: Session.Load proxy accesses DB even if you just access the ID

2010-03-07 Thread Graham Bunce
Fabio, thanks for the reply. I'm in the process of creating a failing test now with just NH, but I've just checked the JIRA and noticed NH-2069, from NH 2.1.1. Looks like the same issue. In case it isn't, can you confirm which version of NUnit (or other) you use - I want to use the Assert.Throws

[nhusers] Re: Session.Load proxy accesses DB even if you just access the ID

2010-03-07 Thread Graham Bunce
btw, I'm really confused now. This blog: "http:// blogs.hibernatingrhinos.com/nhibernate/Default.aspx" and this section "First and Second Level caching in NHibernate" states: "When using the session.Load(id) method NHibernate only instantiates a proxy for the given entity. As long as we only acce

[nhusers] Session.Load proxy accesses DB even if you just access the ID

2010-03-07 Thread Graham Bunce
Hi, I think this is a day for working through my misconceptions about NH. Can someone confirm this is correct behaviour? 1) I get a key from the UI (Web page so I store the key only for performance) 2) I create a proxy in NH using Session.Load in my UI. I assume the row matching the ID exists bec

[nhusers] Re: Set VS. Bag

2010-01-27 Thread Graham Bunce
>The generic IList add IndexOf(9, RemoveAt(), Insert() and Item[] >compared to ICollection<>. All of those deal with index, and if you >really need any of those, it should probably be mapped as a >instead of set or bag. and of those the only useful one I regularly come across is IndexOf(), w

[nhusers] Re: Set VS. Bag

2010-01-27 Thread Graham Bunce
You'd have to change your mapping so that NH knew to use the anonymous property (the property accessor would be set to "backfield") as the second is not using the warehouseList you've created but instead is telling .NET create the backing variable for you and hide it behind the scenes. That's how

[nhusers] Re: Set VS. Bag

2010-01-27 Thread Graham Bunce
I use bag's with IList and don't have any performance problems that i've noticed. In my mapping I also have a key column to map to the SQL table primary key. However in NH 2.1.x you can have ICollection instead and still use sets. If there is anything you need from the IList specific to your appli

[nhusers] Re: HQL query with many-to-many and IN clause

2010-01-21 Thread Graham Bunce
I refer you to my previous post. As far as I'm concerned, the HQL I provided works fine with your mappings as I've listed the SQL that is generated. Are you doing anything wierd? (old version of NH, using NH Fluent or something?) -- You received this message because you are subscribed to the Goog

[nhusers] Re: HQL query with many-to-many and IN clause

2010-01-21 Thread Graham Bunce
Are you sure? Using your mappings (except I use a GUID.COMB generator instead of Native) My SQL equivalent is: select audit0_.Id as Id0_, audit0_.Active as Active0_, audit0_.DateAudited as DateAudi3_0_ from audits audit0_ inner join audit_auditTypes audittypes1_ on audit0_.Id=audittypes1_.auditId

[nhusers] Re: HQL query with many-to-many and IN clause

2010-01-20 Thread Graham Bunce
Oh, and unless you have no choice, try not to use the native generator. Try HiLo or something. Native will be pain sooner or later... -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To un

[nhusers] Re: HQL query with many-to-many and IN clause

2010-01-20 Thread Graham Bunce
Something like; SELECT au FROM Audit au JOIN au.AuditTypes at WHERE at.id IN (:ids) I think -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email to

[nhusers] Re: NHibernate cascade on root object - so many SQL statements

2010-01-18 Thread Graham Bunce
/bump Any comments? Why is the unnecessary (as I understand it) UPDATE being generated by NH? -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email t

[nhusers] NHibernate cascade on root object - so many SQL statements

2010-01-16 Thread Graham Bunce
All, I'm trying to sort out performance on a 1.2 NH app I've inherited. It works on the "Aggregate root" concept, i.e. a parent entity owns children and when the parent it cascades any changes down to the children automatically. The amount of UPDATE/DELETE/INSERT generated against objects that ar

[nhusers] Re: How to configure test environment

2010-01-16 Thread Graham Bunce
Hmm.. Don't use Fluent so can't help you there. If you are sure ALL NHibernate files are in the bin directory that the test runs from, then I'm at a bit of a loss to explain why your error is "can't find NHibernate.dlls" -- You received this message because you are subscribed to the Google Groups

[nhusers] Re: Getting index of a row in a list

2010-01-15 Thread Graham Bunce
Not sure what you mean tbh but Maybe a Multi-query? 1st query gets the count of rows (in case it changed between page interactions) the second to do the paging itself. Get the results, do some calculations from the 1st result to work out the index position the items from the second query would

[nhusers] Re: How to configure test environment

2010-01-15 Thread Graham Bunce
1) Are the NHibernate DLL's in the bin directory that the Unit test code runs in? 2) Is the hibernate .cfg file in the bin directory (and/or settings in test harness config file)? This are the usual scenarios as your test project probably will not reference NH directly, therefore the DLL's will no

[nhusers] Re: HiLo specific to each table

2010-01-12 Thread Graham Bunce
Thanks all for the quick response, and thanks for the example Diego. Oskar -> Is there a reason why you'd have seperate tables over multiple rows in a single table? I believe the HiLo algorithm locks by row?. Is it for performance reasons (i.e. lock by table instead)? I assume the hbm per entity

[nhusers] HiLo specific to each table

2010-01-12 Thread Graham Bunce
All, I know this isn't the "correct" way to do this but I need to know how to use HiLo and have the hilo table store a row for each entity in my system. My reason for this is that I am migrating an existing DB that uses 32- bit integers with Identity over to NHibernate (currently 1.2 but we aim t

[nhusers] Re: Once Exception in Sesssion causing subsequent calls failing

2009-12-31 Thread Graham Bunce
Although I'm aware of this "feature" for ADO exceptions, I'm curious as to why. I know this debate has been had before but I've never seen it come to a conclusion. Why is the session unusable after a "restartable" database errors such as timeout, deadlock, connection failure etc ? These are scenar

[nhusers] Re: Most performant way of getting result count before objects in HQL

2009-12-22 Thread Graham Bunce
Thanks fabio. I thought of that, but I'm concerned that (using your example 1000 limit): a) I need to sort the data via an order by. If I'm going to keep the first 1000 then SQL will need to retrieve all the possible rows, then sort them to get the top 1000. There may be a lot of work for SQL to

[nhusers] Re: MVP WinForms cross session entities

2009-12-22 Thread Graham Bunce
Although I haven't solved it yet, I'm thinking through the same issues for our own architectures here. I think I'm going to go down the route of MVP combined with a Business Conversation (http://fabiomaulo.blogspot.com/2008/12/implementing- conversation-per-business.html) so that the business conv

[nhusers] Most performant way of getting result count before objects in HQL

2009-12-21 Thread Graham Bunce
Hi, I'm wondering if there is a high performance way of getting the result count from a SQL statement (SQL Server) before actually loading the rows into the entity objects, via an HQL query. i.e. Do complicated query - result set = 45000 rows Get count. If count < 1000 load entities At the mome

[nhusers] HQL for collection within a collection...

2009-12-15 Thread Graham Bunce
All, I'm really struggling to come up with the correct HQL for an object configuration such as: Transaction (singular) -> TransactionItems (collection of TransactionItem) --> SendAccount (singular property of a Transaction Item) --> Entries (collection of Entry)

[nhusers] Re: SetLockMode with IQuery and SQL Server

2009-11-25 Thread Graham Bunce
Thanks Fabio. Obvious in the end...:p Usually I don't use it, but I'm trying to reproduce a bug and want to force a database deadlock situation. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googleg

[nhusers] Re: SetLockMode with IQuery and SQL Server

2009-11-25 Thread Graham Bunce
/bump Anybody able to explain what the alias should be for an HQL based IQuery? -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email to nhusers+uns

[nhusers] Re: SetLockMode with IQuery and SQL Server

2009-11-24 Thread Graham Bunce
/bump . or any links to SetLockMode with a Query and what the alias means? Google doesn't come up with much for Querys. There's quite a lot for Criterion... does SetLockMode not actually work for a query? The documentation says its IQuery.SetLockMode() whereas it is actually IQuery.SetLockMo

[nhusers] SetLockMode with IQuery and SQL Server

2009-11-23 Thread Graham Bunce
All, Trying to use SetLockMode with an IQuery. I don't fully understand what the alias means (documentation isn't that clear, could do with an example) but I think it refers to the object being locked. I have the following statement: IDomainClassChild child = session.CreateQuery("FROM DomainClas

[nhusers] Re: Using the in clause (list.Contains) on a substring throws exception

2009-11-16 Thread Graham Bunce
set the substring outside the call? NH-Linq can be a bit flaky sometimes On Nov 16, 2:45 pm, Nieve wrote: > Hello all, > I'm using Linq-to-nh and when I do > query.Where(user => names.Contains(user.Name.Substring(0, 2))); > I get a null reference exception. > Any idea how this should be done a

[nhusers] Object reference not set in BytleCode.xxx.LazyInitializer.Intercept

2009-11-09 Thread Graham Bunce
Hi, I'm getting an odd error after installing our application into a Windows Server 2008 R2 environment. The application works fine running under a development environment (i.e under Visual Studio 2008) but in QA we get an object reference exception in the NH proxy generator: Stack trace: at N

[nhusers] Re: Version tracking question - insert followed by select

2009-11-09 Thread Graham Bunce
I use a SQL generated version so I'm not sure. However, I'm guessing you're using the "version" mapping type.This has an option of generated="never" (meant to be the default). I'm assuming this means let NH do it, not the DB, but I haven't tried it to know for sure. --~--~-~--~~--

[nhusers] Re: Version tracking question - insert followed by select

2009-11-08 Thread Graham Bunce
I'm assuming your version is set to be generated by the DB? In this case, I don't think there is a way to turn off the select - though I too wish there was a way to keep it for updates but a "don't bother this time" for inserts. hopefully someone else will confirm there is such a feature ! -

[nhusers] Re: How to avoid the exception "failed to lazily initialize a collection of role NHibernate..." for some properties of the POCO

2009-11-04 Thread Graham Bunce
> "_ParentPersons" property that by default should return an empty collection > if I don't want to load it explicitly in my DAO My question would be, "why?". As in, why return an empty collection if you don't want to load it explictly? The data either exists, or it doesn't so, because Lazy is tu

[nhusers] Re: Mapping with Timestamp. Miliseconds not persisted.

2009-11-03 Thread Graham Bunce
I don't know about Oracle, sorry, but there was a similar bug I raised recently with the SQL Server 2008 dialect DATETIME2. It seemed the dialect wasn't generating the milliseconds properly as it hadn't overridden the base class correctly. SQL did generate milliseconds as I would expect for Timest

[nhusers] Re: Mapping to domain model - opinions wanted

2009-10-23 Thread Graham Bunce
It's an issue I'm thinking over at the moment as well. You could look at NH collection options such as "batch-size". This can drastically reduce the number of round-trips to the DB. Lazy loading as a default is a good idea, then remove it for those cases where it doesn't make sense (e.g. a custom

[nhusers] Re: Ideas for wrapping NH-Linq queries with common DB retry logic

2009-10-16 Thread Graham Bunce
Any NH guru's got any feedback on whether resubmitting without starting a new session is acceptable in database exception cases such as timeout or deadlock? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "nhusers" gr

[nhusers] Re: Ideas for wrapping NH-Linq queries with common DB retry logic

2009-10-15 Thread Graham Bunce
Ok, worked it out myself, with .NET 3.5 use anonymous methods. e.g. ISerial result = QueryProcessor.Linq(() => Session.Linq ().SingleOrDefault(s => s.SerialId == serialIdentifier)); and public static T Linq(Func executeStatement) { int retry = 0; T result = default(T); d

[nhusers] Ideas for wrapping NH-Linq queries with common DB retry logic

2009-10-14 Thread Graham Bunce
All, In my application I have a repository layer which wraps access to database queries. As NH-Linq has come on the scene we've started using his a lot more for new apps. However, as Linq queries are deferred until first use, I'm not sure how to deal with common DB errors that can be retried - i

[nhusers] Re: Could not determine a type for class Error NH 2.1.0GA

2009-10-02 Thread Graham Bunce
Found it, I think. Coding error - passing a proxy to the SetParameter method, not a Guid. I should just learn not to doubt the NH developers and concentrate on investigating my own team instead :) --~--~-~--~~~---~--~~ You received this message because you are sub

[nhusers] Re: Could not determine a type for class Error NH 2.1.0GA

2009-10-02 Thread Graham Bunce
Ok, this is repeatable now. I'll try to write a test case but it will be in about a week. NH Stack trace (removing product info) at NHibernate.Impl.AbstractQueryImpl.GuessType(Type clazz) at NHibernate.Impl.AbstractQueryImpl.SetParameter[T](String name, T val) Error: "Could not determine

[nhusers] Re: Lazy loading in a reattached entity does not work

2009-09-30 Thread Graham Bunce
I'll be honest, I'm a little confused trying to follow your example. I can tell you've tried to be clear but it's late and I'm tired ;) Any chance of you writing a test case to demonstrate the issue instead? --~--~-~--~~~---~--~~ You received this message because y

[nhusers] Re: DateTime2 SQL2008 millisecond bug?

2009-09-27 Thread Graham Bunce
Dario, I've updated NH-1973 with the latest version of the test case. I'll have a look in the NH code to see if I can work out how to fix it, but I've only just downloaded the codebase and haven't even got it to compile yet ;) --~--~-~--~~~---~--~~ You received th

[nhusers] DateTime2 SQL2008 millisecond bug?

2009-09-26 Thread Graham Bunce
All, I raised a bug (NH-1973) which someone kindly pointed out was a limitation in SQL Server. My mapping file was mapping a .NET datetime to a NH Timestamp field and millisecond precision was being lost. After the update to the bug, I changed my test to the following mapping instead:

[nhusers] Re: DateTime2 SQL2008 millisecond bug?

2009-09-26 Thread Graham Bunce
Oskar. Yes I have, and my test fails to confirm it. using (ISession session = this.OpenSession()) { DomainClass entity = session.Get(1); Assert.AreEqual(DateTime.Parse("2009-09-23 16:28:21.489"), entity.Timestamp); } --~--~-~

[nhusers] Re: Could not determine a type for class Error NH 2.1.0GA

2009-09-25 Thread Graham Bunce
Apologies, you're correct. "Could not determine a type for class Domain.Interfaces.Entities.IDevice" That's all I can recall. Stupidly, I didn't log the stack trace. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[nhusers] Could not determine a type for class Error NH 2.1.0GA

2009-09-25 Thread Graham Bunce
All, Unfortunately I haven't been able to reproduce this to create a failing test but I had the following error with NH 2.1.0GA: "Could not determine a type for class" where the reported class was an Interface declaration. A snip of the mapping file is: .. .. HQL that ca

  1   2   >