[nhusers] How do I scale up performance?

2012-06-10 Thread Peter Morris
Twitter blog claims a record of 6,939 tweets in 1 second - this was 4 seconds after midnight in Japan on New Year’s Day. I decided to run a test, the steps to insert a row would be 3 selects + 1 insert (because of the data structure involved) - I managed 6900 in 578 seconds. Obviously I am not ex

[nhusers] NHibernate and Enterprise Architect

2012-04-04 Thread Peter Morris
Does anyone here build their domain models using EA? I'd like to hear your experiences please. 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, sen

[nhusers] Re: Envers with a PrimitiveType

2012-04-04 Thread Peter Morris
> < unique key, such as Guid.Comb?>> > > No, not currently. It must be some sort of number because it's used in some > queries (eg "<=", "max", "between"). Couldn't the datetime be used for that? Surely people think in terms of Revisions and revision ranges, not revision numbers? > <> > > Hmm.

[nhusers] Re: Envers with a PrimitiveType

2012-03-31 Thread Peter Morris
>It's mandatory that the revision entity has a revision number and a revision >timestamp. However, you can rename it to whatever you want though (both in >domain model and in db schema). Would it be possible to enable us to specify that this could be any unique key, such as Guid.Comb? Also, are

[nhusers] Bi-directional associations

2012-03-28 Thread Peter Morris
Is there a way to get NH to automatically set the single-end of an association when inserting a child into a many end of a bi-directional association? Or perhaps an extension? e.g. purchaseOrder1.Lines.Add(purchaseOrderLine1); would also set purchaseOrderLine1.PurchaseOrder; purchaseOrderLine1.P

[nhusers] Re: Complex validation

2012-03-28 Thread Peter Morris
Thanks, that's just what I needed :) However I don't like the idea of throwing an exception because then you only get the first error rather than a collection of all errors. Or will I have to implement something myself? > There is a not very known interface called NHibernate.Classic.IValidatabl

[nhusers] Complex validation

2012-03-27 Thread Peter Morris
I've been reading through a page describing NHibernate Validator. I was wondering how I would add a very class specific validation, as creating an attribute seems to be the wrong way to write something so specific. For example Description: Start date cannot be before previous end date Psuedo code

[nhusers] Re: Data versioning

2012-03-22 Thread Peter Morris
> You can download docs > herehttp://sourceforge.net/projects/nhcontrib/files/NHibernate.Envers/ > > There's a guy who has written a series of blog posts > herehttp://www.primordialcode.com/blog/post/nhibernate-envers-quick-intro... > > There's plenty of information on the net, primarily for (Jav

[nhusers] Re: Data versioning

2012-03-21 Thread Peter Morris
That sounds excellent. Are there any example apps for this feature? Pete -- 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.

[nhusers] Re: Data versioning

2012-03-20 Thread Peter Morris
Hi Roger > NHibernate Envers might be what you're looking for. However - there the audit > data will be put in seperate > tables.https://bitbucket.org/RogerKratz/nhibernate.envers An important part of the requirement is that I should be able to retrieve an object at a given DateTime and browse

[nhusers] Data versioning

2012-03-19 Thread Peter Morris
Another OPF I have used allows me to specify that a class is versioned. When it is versioned you end up with two additional columns in each relevant class - TimeStampStart, TimeStampEnd. When a new row is inserted you get a TimeStampStart and a null TimeStampEnd. When an object is modified the ex

[nhusers] Re: LINQ2NH and the Repository Pattern

2009-06-18 Thread Peter Morris
I favour having an IExtentService instead - something like public interface IExtentService { IEnumerable AllInstances(ISession session); } The *only* reason I have this is so that when I am writing tests and need data from the DB I can instead mock the IExtentService and return an in-memory Li

[nhusers] Re: LINQ + CaseInsensitive

2009-06-15 Thread Peter Morris
Ah, I see that all string comparisons in SQL Server are case insensitive (not the query specifically). The last time I did SQL by hand I was using InterBase which is case sensitive, so that didn't even occur to me. Thanks :-) Pete --~--~-~--~~~---~--~~ You recei

[nhusers] Re: LINQ + CaseInsensitive

2009-06-15 Thread Peter Morris
If that is the case, how would you perform a case sensitive search? :-) --~--~-~--~~~---~--~~ 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 f

[nhusers] LINQ + CaseInsensitive

2009-06-15 Thread Peter Morris
Can I do a case insensitive string comparison using the current NH Linq implementation? --~--~-~--~~~---~--~~ 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 T

[nhusers] UML

2009-06-05 Thread Peter Morris
Hi all Any good visual studio integrated tools for creating my domain model + mapping for NHibernate? Maybe some kind of UML tool or something? Cheers Pete --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "nhusers

[nhusers] FAO Greg Young - Aggregate Root in NH

2009-05-18 Thread Peter Morris
Hi Greg I have just tested a suggestion by Oren and it seems that it is in fact possible to update an agg-root without modifying it. All you have to do to mark it dirty is to update its version public class Person { public Guid ID { get; set; } public int Version { get; set; } public string N

[nhusers] Re: In memory test

2009-05-04 Thread Peter Morris
> However, for domain-only test-cases, mocked repositories might be better > for > testing, especially with a large number of database objects. Don't say the "R" word :-) Pete http://mrpmorris.blogspot.com http://www.AlterEgos.com - Who do you want to be? --~--~-~--~~--

[nhusers] Re: In memory test

2009-05-04 Thread Peter Morris
>> Ok, then create and remove data in test setups. If you had touched the database, then revert the modification in the test. otherwise they will be slow. << In CapableObjects I use a MemoryPersistenceMapper. It's basically a thread-safe in-memory XML file for testing purposes. I don't have to

[nhusers] Re: In memory test

2009-05-04 Thread Peter Morris
>> Create the master structure once, fill data at TestFixtureSetUp and remove them TestFixtureTearDown should eb nice enough << Then tests can fail as the result of state left from a previous test. I prefer to have a completely fresh environment for each test. Pete http://mrpmorris.blogs

[nhusers] Re: In memory test

2009-05-04 Thread Peter Morris
> Sorry, I don't understand the question... Can you clarify further? Here is the context: http://ayende.com/Blog/archive/2009/04/28/nhibernate-unit-testing.aspx Will creating the DB structure for each test take a long time when there are 200 tables. Pete --~--~-~--~~---

[nhusers] Re: Version

2009-04-28 Thread Peter Morris
>> The type can map to different types but instances will map to only a single aggregate root. << And the use case wouldn't know which the agg-root is? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "nhusers" grou

[nhusers] Re: Version

2009-04-27 Thread Peter Morris
> An instance of an entity always belongs only to a single aggregate root. I thought earlier you had written something about OrderLine belonging to two different kinds of order, one which was raising and one which was raised. I can't find it now though so I may have been someone else. The pro

[nhusers] Re: Version

2009-04-27 Thread Peter Morris
>> While I am aware that we could sprinkle our locks around .. should we have to? Can we avoid these types of hard to find copy/paste bugs by allowing say a declaration that an object is an aggregate root? << Take into account though that your logical region of validation differs based on what

[nhusers] Re: Version

2009-04-27 Thread Peter Morris
>> Customer Contact Address for the sake of discussion let's imagine that these are all entities .. Customer c = CustomerRepo.Fetch(id); c.Contact.Address.Street = "testing"; UnitOfWork.Commit(); << Your use-case knows why you are doing what you are doing. So it would load + loc

[nhusers] Re: Version

2009-04-27 Thread Peter Morris
>> with AOP the problem is finding the root (it might be 5 levels deep). I was looking at Peter's suggestion but don't like what it requires. I am currently looking at a way to do this only in proxies but the trick is in finding out what aggregate root we are under while not having the id carried

[nhusers] Re: Version

2009-04-27 Thread Peter Morris
> I was hoping some people had some brilliant solution that had just alluded > me :( Could your solution be either to use Get with a lock mode Session.Get(customer, LockMode.Write); or if you already have the customer reference via a repository just to lock it? Session.Lock(customer, L

[nhusers] Re: Version

2009-04-24 Thread Peter Morris
> I see what you are saying build an interceptor ... then make my root traversable from all thechildren .. have interceptor make the session.Update call .. Is that correct? < It's the way I have done it in ECO (capableobjects), I make each part implement IAggregatePart which has a GetRootOb

[nhusers] Re: Version

2009-04-23 Thread Peter Morris
I wonder if this is the kind of thing that would do it? //Mapping for your class here //End of mapping for your class This way it's a composite part of the aggregate root class? Pete http://mrpmorris.blogsp

[nhusers] Re: Version

2009-04-23 Thread Peter Morris
Hi Greg > how can I define child objects to use a parent's object versioning number? > > i.e. > > Student >classes > > If there is a change to any class the student's version number changes > > The specific scenario is for a DDD aggregate. I think the aggregate part wouldn't have a version.

[nhusers] Re: IoC

2009-04-17 Thread Peter Morris
I think the link to here http://nhforge.org/doc/nh/en/index.html#manipulatingdata-interceptors Is probably what I am after. I presume I only need to do a UnityContainer.BuildUp(entity) in the OnLoad method. If so then that is the rehydrate solved. My other problem is how to inject dependenci

[nhusers] Re: IoC

2009-04-17 Thread Peter Morris
> But you can use the alternative constructor. Sorry Fabio, I don't know what you mean. Pete http://mrpmorris.blogspot.com http://www.AlterEgos.com - Who do you want to be? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the G

[nhusers] Re: IoC

2009-04-17 Thread Peter Morris
> http://www.nhforge.org/doc/nh/en/index.html#persistent-classes-lifecycle ? That wont do the trick. It is a callback mechanism for the entity instance, what I need is a call back mechanism for the session so that I can inject dependencies into the entity via an injection method. Pete h

[nhusers] IoC

2009-04-17 Thread Peter Morris
Is there a hook somewhere in NH that gets called each time an object is rehydrated? I want to call an InjectionMethod on each instead to inject some dependencies, I don't need to use an alternative constructor, I just need the hook :-) Pete http://mrpmorris.blogspot.com http://www.Alter

[nhusers] Re: MockRepository.GenerateMock

2009-04-14 Thread Peter Morris
Sorry, wrong group, obviously :-) Pete http://mrpmorris.blogspot.com http://www.AlterEgos.com - Who do you want to be? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, se

[nhusers] MockRepository.GenerateMock

2009-04-14 Thread Peter Morris
[TestMethod] public void Publish_LogsPublishedPlayerMessages_ForPlayer() { var mockActivityLoggingService = MockRepository.GenerateMock(); mockActivityLoggingService.AddDetail("Hello"); } Shouldn't this throw some kind of Unexpected exception? This test is passing. I want to ens

[nhusers] Re: Is this right?

2009-03-27 Thread Peter Morris
"I realized that when lazy loading NH does not touch the database before creating the proxy object. Now how should NH know if it should create a ProfileA-proxy or a ProfileB- proxy without checking the database for the discrimiator value? " This is a big problem in my opinion. Surely NH could cr

[nhusers] Re: Is this right?

2009-03-27 Thread Peter Morris
>I mean, i have a service, i request an object, i don't know why i'm asking > for it? Correct. > In general for a really complex system I build a DTO to send to the > client, Imagine the app manages the automatic payment of allowances on a period basis. The client has just indicated that Em

[nhusers] Re: Is this right?

2009-03-27 Thread Peter Morris
> You don't know what you are giving your object for? Well, firstly if I use a Repository pattern, no. I would want to write public interface ICustomerRepository { Customer GetByID(int id); } and obviously wouldn't want public interface ICustomerRepository {

[nhusers] Re: Is this right?

2009-03-27 Thread Peter Morris
>B is not using projection, it is using a fetching strategy which will load > it eagerly when needed and will leave the lazy loading if you are not > going > to request this data in the use case. In a complex domain the number of possibilities could be so large that it would be nearly impossibl

[nhusers] Is this right?

2009-03-27 Thread Peter Morris
Let's say I have an object with an association to a single object and the mapping doesn't specify that NH should fetch the associated object automatically. Now when my app layer fetches that object and wants to do some processing on it (which uses that association) I must either A: Use proxie

[nhusers] Re: IoC into business class instances

2009-03-27 Thread Peter Morris
>I wouldn't use container.Resolve No I agree, I'd most likely have a SongBuilder injected into the class which needs to create the song. >> Beyond all of that I would say that this is a great place where cqs coud help << Which I would like to see an example of :-) >> ... are the varying h

[nhusers] Re: IoC into business class instances

2009-03-26 Thread Peter Morris
>> Did you mean persistent or transient? I need a transient dependency to a >> service. >Not surprisingly I am using the definition of transient itself not >refering to a transient vs persistent object. In other words for 95+% >of cases the object does not need to *remember* which service to us

[nhusers] Re: IoC into business class instances

2009-03-26 Thread Peter Morris
Hi Greg >> While you have done your very best to try to find and edge case << I'm not actually looking for a corner case here I'm just trying to find a way to implement what I currently need, but it does make me wonder about injecting dependencies into my domain. Surely there are circumstance

[nhusers] Re: IoC into business class instances

2009-03-26 Thread Peter Morris
Hi Anne > Regarding your actual algorithm, it sounds like you're making > something very similar to soundex. Yes, it is basically that, for now at least. I will look at what algorithm I will use when I am happy with the approach. Pete http://mrpmorris.blogspot.com --~--~-~--~

[nhusers] Re: IoC into business class instances

2009-03-26 Thread Peter Morris
Hi Fabio > You can configure NH to use the field (including the backfield of an > autoproperty) and don't have the setter. Thanks, I am aware of that, the problem is an OOP one really. If I don't have a setter then I wont be able to set the value without using a parameterised constructor, and

[nhusers] Re: IoC into business class instances

2009-03-26 Thread Peter Morris
>> Haven't read the whole message (i will in a moment) but a quick answer would be did you try NH Search, or pure lucene indexing? << No, neither, but I am mainly interested in the conceptual part of the question :-) Thanks Pete http://mrpmorris.blogspot.com --~--~-~--~~--

[nhusers] Re: Using Hi/Lo Generator

2009-03-26 Thread Peter Morris
> It is the thing that you last said, when exhaust a new Hi value is obtained, Lo values are incremented everytime an object is persisted. < Ah I see, that makes sense. I am confusing it with the other approach where only the exact number of IDs are requested when an update is required. Pete

[nhusers] Re: Using Hi/Lo Generator

2009-03-26 Thread Peter Morris
> and as for the people asking about what the behaviour was - the simplest > thing is to setup a quick two-entity domain with hilo id, new one instance > of each, session.Save them both and peek into the generated data. As I am still at theory level and can't yet do that may I ask a question? :-

[nhusers] Re: IoC into business class instances

2009-03-26 Thread Peter Morris
> Fabio gives the answer but do you really need to do it? Not sure :-) I have a Song class which has a Name property. When the user searches for a song I want to list songs with a similar name to what they entered rather than the exact string. To achieve this I am considering doing somethin

[nhusers] Re: IoC into business class instances

2009-03-25 Thread Peter Morris
> http://fabiomaulo.blogspot.com/2008/11/entities-behavior-injection.html I think this link from your link will be more useful: http://nhforge.org/doc/nh/en/index.html#manipulatingdata-interceptors I can just execute Container.BuildUp(entity.GetType(), entity); That should do it. Learning

[nhusers] IoC into business class instances

2009-03-25 Thread Peter Morris
Hi all Sorry if this is a basic question :-) If some of my business classes have dependency injection how do I ensure that these dependencies get injected? I am assuming either A: There is a hook somewhere that I can use for when NH creates rehydrated instances. B: There is a post create hoo

[nhusers] Re: Contexts

2009-03-25 Thread Peter Morris
> No problem, but a real functional example would be better for NH's users, > believe me. I'll see what I can do. Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "nhusers

[nhusers] Re: Contexts

2009-03-24 Thread Peter Morris
Hi Fabio > Interesting.Do you have a public example ? I'm a complete newbie with NH so no :-) The implementation though would be something like var mainContainer = new UnityContainer(); //Registration of new feature mainContainer.AddNewExtension(); //Register repositories etc from some confi

[nhusers] Contexts

2009-03-24 Thread Peter Morris
I have finally tried the code in this post http://unity.codeplex.com/Thread/View.aspx?ThreadId=46415 It works great for specifying services which rely on a context that is not defined until a child container is created. Now I can easily have a UnitOfWork for unique contexts without having to w

[nhusers] Re: One to many - code implementation

2009-02-26 Thread Peter Morris
I've gone with this... 01: Direct access to the field on the parent 02: A ReadOnlyList for accessing the children private ISet comments = null; public ReadOnlyCollection Comments { get { return new

[nhusers] Parent-child, bizarre SQL

2009-02-26 Thread Peter Morris
Here is the SQL generated: SELECT TOP 1 ID1_0_, Title1_0_, Body1_0_, PostedOn1_0_ FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.ID1_0_, query.Title1_0_, query.Body1_0_, query.PostedOn1_0_, query.__hibernate_sort_expr_0__ FROM (SELECT this_.ID as ID1_0_, this_

[nhusers] One to many - code implementation

2009-02-26 Thread Peter Morris
Hi all I've recently started to evaluate NHibernate and have a question regarding implementation of one-many associations. Let's say we have [ParentClass] Parent 1* Children [ChildClass] It seems to me that when considering an in-memory model only I would do something like this ParentCl

[nhusers] Re: Why is 'cascade' not an enumeration in nhibernate-mapping.xsd?

2009-02-24 Thread Peter Morris
> http://groups.google.com/group/nhusers/browse_thread/thread/ac5979588ef67755 I'd have stuck with a single-value for the attribute, and introduced a sub-node which may repeat for this so that the user can specify multiple Pete http://mrpmorris.blogspot.com --~--~-~--~~--

[nhusers] IoC and NHibernate

2009-02-21 Thread Peter Morris
Hi all Not sure if this is off-topic or what :-) When I create a repository interface it looks a bit like this public interface BlogEntryRepository { BlogEntry GetByID(ISession session, int id); } I am a bit suspicious of the "ISession" parameter. I suspect it shouldn't b

[nhusers] Re: Objects State Validation && Business Rules in non Trivial Domain Models

2009-02-20 Thread Peter Morris
>> Doesn't NHibernate do some kind lock to do a version check (locking update on that object for the time of the DB transaction, SELECT FOR UPDATE) ? << Version numbers are for checking conflicts on the *same* object, they can't be 100% reliable for checking conflicts on objects you are not upd

[nhusers] Re: Objects State Validation && Business Rules in non Trivial Domain Models

2009-02-20 Thread Peter Morris
>> I'm assuming that NHibernate does the version check at commit/flsh time. In other words NHibernate commits all data and version ckecks in a single database transaction. If that is not the case, this doesn't work! << Even if it *is* the case, without some kind of update-lock it still wont work

[nhusers] Re: Objects State Validation && Business Rules in non Trivial Domain Models

2009-02-19 Thread Peter Morris
Hi Nuno > Usually once you dispatch something the date is locked But that would just be changing the question to make the answer easier :-) The example isn't meant to be realistic, just simple :-) > NHIbernate (or any other system that cares for it). In the case of > NHibernate it will lock

[nhusers] Re: Objects State Validation && Business Rules in non Trivial Domain Models

2009-02-19 Thread Peter Morris
Dispatch.Date = Today - 1 Delivery.Date = Today + 1 Dispatch.Date must be <= Delivery.Date Delivery.Date must be >= Dispatch.Date User 1: Fetch Delivery User 2: Fetch Dispatch User 1: Update Delivery.Date - 2 days User 2: Update Dispatch.Date + 2 days User 1: Check constraint, it's valid, save.

[nhusers] Re: Objects State Validation && Business Rules in non Trivial Domain Models

2009-02-18 Thread Peter Morris
> It seams that we can set the proxy factory to be used by NHibernate: > proxyfactory.factory_class in the config file. Basically the it would > intercept a call to the method, check if that method was a business > rule, if that was the case it would lock the object. Locking the > object will forc

[nhusers] Re: Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
Hi James > You should also bare in mind that you're very early on in the book. > Perhaps > the example could've been structured better, but you're still only on the > 2nd chapter; you can't expect everything to have been explained already > otherwise you'd be at the end of the book. Obviously

[nhusers] Re: Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
> To elaborate a little on what Ken said. HQL is the Hibernate Query > Language, > which means you're querying NHibernate rather than your database. It > probably should have been mentioned in the book, but this means that your > queries are case sensitive for entities (keywords are insensitive);

[nhusers] Re: Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
> just remember - HQL (and criteria API) are about OBJECTs not Database > fields. > and please do take notice to the error messages. They tend to be very > informative - the use of 'property' should have raised the red flag for > you. I spotted the word property, and if it had been "firstName" o

[nhusers] Re: Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
Ken. Yes, you are correct, thank you very much! I would never have suspected case sensitivity! Pete http://mrpmorris.blogspot.com http://www.capableobjects.com - Think domain, not database --~--~-~--~~~---~--~~ You received this message because you are s

[nhusers] Re: Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
n the book and this one is not addressed later, so if someone can explain this to me I'd appreciate it. Thanks Pete http://mrpmorris.blogspot.com http://www.capableobjects.com - Think domain, not database > > On Sun, Feb 15, 2009 at 1:12 PM, Peter Morris wrote: > >>

[nhusers] Re: Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
> Are you referring to "Hello World" with NHibernate? Because if you are, > there are more steps after the one you're talking about. 2.1.5 creates the > code to save, then it carry's on explaining things until you get to 2.1.8 > where you actually configure your application. Yes I am, and I am al

[nhusers] Re: Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
The book simply says this 01: Create a console app 02: Add an Employee class public class Employee { public int ID; public string Name; public Employee Manager; public string SayHello() { return string.Format( "'Hello World!', said {0}.", Name); } } 03: Create the DB 04: R

[nhusers] Re: Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
Hi Tuna Yes. I downloaded 2.0.1 from the website. >> I guess you are using 2.0 versions and it doesn't have "hibernate.dialect" thing. New versions use "dialect" only. << Could you tell me what is wrong with the code example I posted so that I can fix it? This is my first exposure to NHibern

[nhusers] Could not find the dialect in the configufation

2009-02-15 Thread Peter Morris
Hi all. I'm working through the first example in "NHibernate in Action" and guess what? It doesn't work! using System; using System.Collections.Generic; using System.Linq; using System.Text; using NHibernate; using NHibernate.Cfg; using ConsoleApplication30.Model; namespace ConsoleApplication3