> I always commit the NH transaction. I'm not sure. Try it and see.
Inside a transaction scope, all db transaction using objects
subscribe to a 'manager' which tells the transaction scope how the outcome
of their db transaction turned out: rollback or commit. When you commit a db
transaction (through an nh transaction) it should vote for 'commit' at the
controlling transaction scope.
At transactionscope complete, all controlled transactions' votes are
checked and if one wants to rollback, everything is rolled back or
committed. This is done by calling the subscribed managers that the
transactions can be committed or have to be rolled back. At that moment NH's
code gets a call to commit or rollback. So if you call it beforehand, it
simply should vote for commit and do nothing else but wait for the scope's
final 'judgment' ;)
FB
> On Wed, Aug 18, 2010 at 6:59 AM, Jacob Madsen <[email protected]> wrote:
>
>
> "session.Transaction.Commit()" is invoked by the NH internals, when
> transactionScope.Complete() is invoked, right?
>
>
> On Wed, Aug 18, 2010 at 1:56 PM, Jacob Madsen <[email protected]>
wrote:
>
>
> Ahh.. great details!
>
> On Wed, Aug 18, 2010 at 1:53 PM, Fabio Maulo
> <[email protected]> wrote:
>
>
> First of all thanks to avoid the annoying discussion
> about "I don't want use NH's transaction" and try it as I said you.
>
> In releasenote.txt under
> ** BREAKING CHANGES from NH1.2.1GA to NH2.0.0
> you can find this
> * AutoFlush will not occur outside a transaction -
> Database transactions are never optional, all communication with the
> database must occur inside a transaction, whatever you read or write data.
>
> The NH's transaction is, sorry to be redundant, the
> NH's transaction. You have to use it because NH need it to take in account
> all operations under NH responsibility (it include cache, UoW and
> transactionscope).
>
> Because NH's transaction is not 1:1 with
DB-transaction
> the TransactionScope is not a substitute of NH's transaction.
>
> On Wed, Aug 18, 2010 at 8:37 AM, Jacob Madsen
> <[email protected]> wrote:
>
>
> Love the feature :-)
>
> Why do you also begin a nhibernate
transaction?
>
>
>
>
> On Wed, Aug 18, 2010 at 1:08 PM, Fabio Maulo
> <[email protected]> wrote:
>
>
>
> using(var transactionScope = new
> TransactionScope())
> using(var session =
> sessionFactory.OpenSession())
> using(var tx =
> session.BeginTransaction())
> {
> var someEntity =
> session.Get<SomeEntityType>(someId);
>
> someEntity.Name = "bla";
> ....
> transactionScope.Complete();
>
>
> NH will use autodirty check
>
>
>
> On Wed, Aug 18, 2010 at 7:53 AM,
Jacob
> Madsen <[email protected]> wrote:
>
>
> So I do not need to make an
> explicit Update(someEntity) call?
>
> using(var transactionScope =
new
> TransactionScope())
> using(var session =
> sessionFactory.OpenSession())
> {
> var someEntity =
> session.Get<SomeEntityType>(someId);
>
> someEntity.Name = "bla";
>
>
session.Update(someEntity); // I
> want to avoid these explicit Update-calls by tracking the (dirty) entities
> in a session and do a single call to a "void SaveChanges()" method. The
> "SaveChanges" method should do the updating on the entities in a session.
I
> still want to explicitly insert new entities with session.Save(newEntity),
> which I abstract and in a method called "Store".
>
>
transactionScope.Complete();
> }
>
>
> On Tue, Aug 17, 2010 at
10:30 AM,
> Dwarrel <[email protected]> wrote:
>
>
> Yes, you would not
want to
> use it for that reason, flush will do that
> automatically.
Unfortunately
> I do sometimes crave for a way to see
> which objects are in
the
> session. Sometimes I would want to evict all
> objects of a certain
type
> from the session cache. This if you have a
> longer running
session and
> someone else has updated the DB values.
> There is no known
way of
> evicting say all purchase info and then re-
> run a query to load
the
> relevant ones. If you don't evict them then
> you get a strange
mix of
> stale and current information as your query
> result (even when
having the
> version number available!)
>
>
> On Aug 16, 3:33 pm,
Jason
> Dentler <[email protected]> wrote:
> > Automatic dirty
checking
> will take care of this when the session is flushed
> > (which normally
happens
> when you commit a transaction)
> >
> >
> >
>
> > On Mon, Aug 16,
2010 at
> 4:27 AM, Jacob Madsen <[email protected]> wrote:
> > > Hi all,
> >
> > > Is there a
method to
> retrieve references to all entities known by a
> > > session
> >
> > > using (var
session =
> sessionFactory.OpenSession())
> > > {
> > > var entity =
> session.Get<SomeType>(someId); // "entity" is now
> > > known by the
session
> > > ....
> > > var
allKnownEntities
> = /* here I want to retrieve all entities
> > > known/attached
to a
> session */
> > > ....
> > > }
> >
> > > I want to
implement a
> "void SaveChanges()" method that will Update all
> > > modified
entities known
> by a session.
> >
> > > Cheers!
> >
> > > --
> > > 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]
> <mailto:nhusers%[email protected]>
> <nhusers%[email protected]
> <mailto:nhusers%[email protected]> ->
>
> > > .
> > > For more
options, visit
> this group at
>
> >
> >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
> >
> > - Show quoted text
-
>
> --
>
> 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]
> <mailto: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]
> <mailto:nhusers%[email protected]> .
> For more options, visit this
group
> at http://groups.google.com/group/nhusers?hl=en.
>
>
>
>
>
> --
> Fabio Maulo
>
>
>
>
>
> --
>
> 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]
> <mailto: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]
> <mailto:nhusers%[email protected]> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
>
>
>
> --
> Fabio Maulo
>
>
>
>
>
> --
> 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]
> <mailto: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]
> <mailto: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.
--
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.