|
Joutsen Persistence
v0.2.1
|
The persistence part of the Joutsen framework offers easy to use base implementations to persist and retrive objects. The framework uses the repository pattern to abstract from the actual persistence technology.
Currently the only available implementation uses NHibernate to manage objects stored in a database.
Simply download the latest assemblies and add them to your .NET project or build them yourself by cloning the repository and build the solution using the build.sh file from the scripts folder.
To use the offered base repositories for NHibernate simply create an instance of them or sub class them and pass the path to the configuration file to the constructor. Different configurations are also supported. Simply pass different paths to the constructor and the objects will be read and written to the databases specified in the configuration files. Once created it is possible to create, store, modify and delete instances in the databse:
If instances cannot be created by a parameterless constructor or if the instances are stored in the database using an interface simply use the InterfacedEntityRepository and implement the Create() method.
If more complex logic is required to retrieve instance from or store instances in the database a subclass can be created with additional methods. In these methods the NHibernate session object can be used directly to implement any kind of logic. To ease the handling of transactions and sessions the repositories offer the methods ExecuteInSession and ExecuteDbCommand which handle the database operations by either executing them in an existing session if available or in a separate session.
API documentation is available in the code or here. It can also be generated by using the script docs-html.sh.
Tests can be run using NUnit by using the projects in the test folder. For unit test simply run
Build and tests are also automatically run on the Jenkins CI server at https://ci.norsecorby.de/.
1.8.13