Corrected rounding errors when creating inserts for entity types

As `hash` returns a `NSUInteger`, using `%u` as the format string would mean that the longer integers would overflow. Using `%lu` and casting to a `unsigned long` ensures this does not happen. Also when fetching the entity type now uses `sqlite3_column_int64` to also ensure that no overflowing happens.