>From what you are describing, NHibernate does not seem to be a candidate
part of your architecture. NHibernate is only designed to work with multiple
threads where those threads are unlikely to update the same entity instance
and when the _occasional_ collision does happen it is resolved by throwing
an error on one thread, notifying that thread that it failed.

It is not easily possible with NHibernate to load an entity instance in one
thread, then use that instance to fire new threads and update the instance
from the new thread. It may be possible if the first thread evicts the
instance before the new thread tries an update and the new thread performs a
read before the update. Sound very messy.

A cache like Microsoft AppFabric, formerly Velocity, may make this possible
with NHibernate, but that is a very specialized application of the
technology (not usually attempted by an individual who does not have
experience with all the tools involved).


John Davidson


On Wed, Jul 21, 2010 at 3:31 PM, nadav s <[email protected]> wrote:

> if different threads are updating the same instance in the same time,
> you'll have problems.
> if the same entity isn't updated by different threads in the same time, you
> can use multiple sessions. If they are, then you gotta explain why and how
> you're doing so, because there are concurrency issues with this, because one
> thread is overriding the changed of another thread.
>
>
> On Wed, Jul 21, 2010 at 10:20 PM, Giulio Petrucci <
> [email protected]> wrote:
>
>> Hi John,
>>
>> thanks for your reply.
>>
>> On Wed, Jul 21, 2010 at 8:13 PM, John Davidson <[email protected]>
>> wrote:
>> > It actually sounds as if a cache solution is what you require, but it is
>> > difficult to tell exactly from the problems you are encountering. What
>> is
>> > the major use case for your application?
>>
>> What do you mean with "use case"? My application is a windows service,
>> periodically reading some data from a db (using NHibernate, of
>> course). The model is like this:
>>
>> class Matrix {
>>  IEnumerable <Column> ColumnSet { get; }
>>  IEnumerable <Row> RowSet { get; }
>>  void AddColumn(Column c);
>>  void AddRow(Row r);
>> }
>>
>> class Column
>> {
>>  Matrix Matrix { ... }
>>  String Label { ... }
>> }
>>
>> class Row
>> {
>>  Matrix Matrix { ... }
>>  IEnumerable<Element> ElementSet { get; }
>>   String Label { ... }
>> }
>>
>> class Element {
>>  Int32 Value { get; }
>>  Row Row { get; }
>>  Column Column { get; }
>> }
>>
>> so, my service every 10 minutes (for example), loads some Matrix
>> instances. Then for each column, iterates over all the elments and
>> perform some operation, calling a remote web service. Those
>> operations, which involve read/write access to the data layer, have to
>> be executed in a "parallel" way, so they're actually execute in
>> different threads.
>>
>> Don't know if I've actually answered your question, If not, please,
>> let me know. :-)
>>
>> Thanks again,
>> Giulio
>>
>> --
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to