Since you are talking about inserting values, I'd rather use read
uncommitted, so that ValidateIsUnique can see uncommitted values in
the table.
However, I'm not sure you really have a one-to-many. This implies a
many-to-one (BelongsTo) from the other side. Is this the case or do
you have a hidden many-to-many relation (by using HasMany with simple
types)?

-Markus

2009/5/30 ebaker280 <[email protected]>:
>
> Thanks for your reply. I am, in fact, creating a new SessionScope,
> making my Model instance modifications, and calling Dispose() on the
> session in each thread. By your suggestions, I have tried using a
> TransactionScope session, and set the connection.isolation to
> "Serializable". Now, the first thread that gets the chance to creates
> the single unique string value in the table, but it appears that the
> other threads fail due to timing out.
>
> I'm calling a method in my model that looks like this:
>
>    public static Thing FindOrCreateByName(string name)
>    {
>        Thing obj = Thing.FindFirst(Expression.Eq("Name", name));
>        if (obj == null)
>        {
>            obj = new Thing() { Name = name };
>            obj.Create();
>        }
>        return obj;
>    }
>
> Am I just barking up the wrong tree here?
>
> --
> Eric
>
> On May 29, 3:33 pm, Markus Zywitza <[email protected]> wrote:
>> Sounds like these threads share a SessionScope and thus it's
>> Transaction. You should rather have a SessionScope per request. You
>> can then tweak that threading behaviour by using transaction isolation
>> settings in the config as each request will have its own transaction
>>
>> -Markus
>>
>> 2009/5/29 ebaker280 <[email protected]>:
>>
>>
>>
>> > I'm using Castle AR in a WCF service, running on a net.tcp endpoint. I
>> > have a table that will store a bunch of unique strings, and other
>> > tables will reference it in a one-to-many relationship.
>>
>> > The problem is that if I have several clients trying to create a row
>> > with the same string simultaneously on their own threads, each one
>> > will succeed, and I'll end up with 'n' number of duplicate strings in
>> > the table. I've tried using ValidateIsUnique on the property, but it
>> > seems to only work within its own thread.
>>
>> > I've been able to use locks to make this work, but that seems terribly
>> > inefficient. Am I missing something simple with regards to
>> > SessionScope or something?
>>
>> > Thanks
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to