views:

62

answers:

1

Hi,

I am using FNHibernate and its default is 'table per subclass' for inheritance mapping. This seems to be the cleanest way to do things but it has its downsides too. My problem is that I have to seed the database with lots of tab separated data. I have tried to do this via repositories/services (i.e. via FNHibernate) but this is very slow so I switched to SQL:

http://stackoverflow.com/questions/3289865/insert-data-into-several-tables-possibly-using-output-sql-server-2005

I am currently using loops to seed the database but this takes ages. I am just wondering whether there are faster ways to seed a 'table per subclass’ type database or do I have to switch to 'table per class hierarchy' mapping?

I am sure that other people must have encountered the same problem. Any feedback is very much welcome. Many thanks in advance!

Best wishes,

Christian

A: 

I have no idea how much records we're talking about and how you loop exactly but here are some ideas:

  • If you are using the regular session, be sure to flush and clear the session at regular intervals. Have a look at this post (applies to NHibernate too). ~or~
  • Consider using the stateless session. This blog post shows how to use it. ~or~
  • Switch to raw SQL.

Similar questions

Pascal Thivent