Generic database entity to object translation and query framework