Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fluent NHibernate - SessionSource and PersistenceSpecification

1) Could anyone give a clear explaination of what SessionSource is intended for, and why would I want to use this rather than just Fluently.Configure()....BuildSessionFactory()?

2) What is the PersistenceSpecification class for? I know you can use it for persistence testing (http://wiki.fluentnhibernate.org/Persistence_specification_testing), but I've seen it crop up in other scenarios, but am not really sure what for.

Thanks!

S

like image 680
UpTheCreek Avatar asked Sep 18 '09 11:09

UpTheCreek


1 Answers

1) SessionSource is little more than a ISession factory. One particularly useful usage of it is in SQLite in-memory tests. See, SQLite has a in-memory mode, in which the database is never written to a file. This mode is very useful for unit-testing your persistent classes since it's very fast. Problem is, this database lasts exactly one connection. The moment the connection is closed, the database vanishes. Therefore, SingleConnectionSessionSourceForSQLiteInMemoryTesting is used to ensure that the same connection is always used.

2) It's just like you say, it's used for persistence specification testing as explained in the wiki... where else did you see it?

like image 53
Mauricio Scheffer Avatar answered Oct 04 '22 17:10

Mauricio Scheffer