[Opensim-dev] DB - NHibernate tests (part 1)

Impalah impalah at gmail.com
Wed Feb 6 22:06:14 UTC 2008


Hi everyone:

I've uploaded a file to my web page with a c# project testing NHibernate:
http://ai-designstudio.net/index.php?option=com_docman&task=doc_details&gid=40&Itemid=88889037&lang=en

Please, does not expect a miracle right now, it's just only a massive
insertion test for checking if everything runs ok.

The zip includes a VC#.NET project and a sql file for MySql (I haven't time
to translate ALL the "model" I used to mssql and sqlite). Check the file
hibernate.cfg.xml and substitute dbName, user and password.

The project does a raw insert of 100 registers into 4 tables. 3 tables have
relationships between them (Expressed in "object words", there are 3 clases
with objects inside. Hibernate does automatically the selects to get the
registers, we only work with OBJECTS). The full proccess took less than 1
second. I have tested it both in mono and .NET. Ah!!! I was not sure about
BLOB fields, but seems to work ok. I've tested too 10000 insertions
(converted in 50000 due to the model), it took 1:30 minutes, not too bad.

This evening, at work, I could try insertions in mssql and sqlite, just
changing the parameters of hibernate.cfg.xml (I hope tomorrow could have a
better example with those databases). If someone wants to test against this
dbs, just uncomment the lines indicated and comment the rest.

What we gain with this:
- DB independence (even Oracle, postgresql, Access, etc. could be used).
- Only the DB module has to know the mappings, the rest of the model will
just use the objects provided.
- Transaction management (increases security).
- (This one may be interesting) The objects provided could be serialized for
transmitting info between servers or for import/export.
- Using hbm2ddl NHibernate can create automatically the tables. We doesn't
need more *sql files for every db.


And the TODO list (both for me and for the rest of the team):
- Check timing with selects and, overall, selects in objects with
relationships (in Java it uses to be slow sometimes if the db model is not
optimized; slow is around 1 second using several JOINS)
- Investigate a way to configure without the xml attached to every mapped
object. There is a NHibernate extension to do that with attributes (like the
Java anotations I use everyday) but I haven't tested it yet.
- How to put everything into OpenSim without affecting the rest of the
modules. I don't know OS enough to do this alone.
- For the next future: if everything works ok with NHibernate, OS, and the
actual db model, create a more eficient and normalized db model.

Well, that's all folks.

Greetingzzz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-dev/attachments/20080206/260200af/attachment-0001.html>


More information about the Opensim-dev mailing list