moved all database specific code to typeAdapter class