tags:

views:

192

answers:

2

Using NHibernate 2.0:

I have an object with some changes on it and I am about to session.Update() it. Is there some way I can preview the SQL that will be executed without actually executing it?

A: 

Hi!

Why would you want to do that? You can show it by the show-sql setting, but it will be executed also. You could use NHibernate againt an in-memory database like SQLite if you want to test the mapping ;)

Best Regards
Oliver Hanappi

Oliver Hanappi
I know, but I'm stuck with this live legacy database, I'm paranoid, and I'm curious. :-)
Per Erik Stendahl
@Per Erik, you are walking on thin ice my friend. I would seriously suggest working off a backup/snapshot, then would be free to test and break things.
mxmissile
+2  A: 

You could wrap a transaction around the session and perform the update without committing.

lomaxx
Good idea, not best performance, but for tests good enough, if NHibernate does not lock too many rows.
Oliver Hanappi
Yes, I was thinking about that. I guess this is the only sure way of seeing the generated SQL in all it's glory! :-) Thanks.
Per Erik Stendahl
Note to self: .Flush() before tx.Rollback()
Per Erik Stendahl